S
shapper
Hello,
I am trying to send an email using Asp.Net 2.0.
I am getting the following error:
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The
server response was: No such user here at
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception) at
System.Net.Mail.SmtpClient.Send(MailMessage message)
The strange thing is that the email box really exists.
My code is as follows:
1 ' Define user profile
2 Dim userProfile As ProfileCommon =
Profile.GetProfile(tbUsernameRecover.Text)
3
4 ' Define user name
5 Dim name As String = userProfile.Personal.Name
6
7 ' Define user email address
8 Dim email As String = user.Email
9
10 ' Reset user password
11 Dim newPassword As String = user.ResetPassword()
12
13 ' Create new mail message
14 Dim message As New System.Net.Mail.MailMessage
15
16 ' Define mail message properties
17 With message
18
19 ' Define mail message properties
20 .Body = Resources.Email.PasswordReset_Body & newPassword
21 .From = New
System.Net.Mail.MailAddress(ConfigurationManager.AppSettings("Email.NoReply.Address"),
ConfigurationManager.AppSettings("Email.NoReply.Name"))
22 .IsBodyHtml = False
23 .Subject = Resources.Email.PasswordReset_Subject
24 .To.Add(New System.Net.Mail.MailAddress(email, name))
25
26 End With
27
28 ' Create and define the SMTP client
29 Dim smtpClient As New System.Net.Mail.SmtpClient
30
31 ' Get mailSettings section from web.config
32 Dim mailSettings As
System.Net.Configuration.MailSettingsSectionGroup =
ConfigurationManager.GetSection("system.net/mailSettings")
33
34 ' Define smtp client properties
35 If Not mailSettings Is Nothing Then
36 With smtpClient
37 .Port = mailSettings.Smtp.Network.Port
38 .Host = mailSettings.Smtp.Network.Host
39 .Credentials = New
System.Net.NetworkCredential(mailSettings.Smtp.Network.UserName,
mailSettings.Smtp.Network.Password)
40 End With
41 End If
42
43 ' Send the mail message
44 Try
45
46 ' Send the mail message
47 smtpClient.Send(message)
48
49 Catch ex As Exception
50
51 Response.Write(ex.ToString)
52
53 End Try
And in my web.config file I have:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network defaultCredentials="true"
host="mail.mydomain.com" password="pass" port="25"
userName="(e-mail address removed)"/>
</smtp>
</mailSettings>
</system.net>
This email account exists and it is working!
Could someone tell me what am I doing wrong here?
Thanks,
Miguel
I am trying to send an email using Asp.Net 2.0.
I am getting the following error:
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The
server response was: No such user here at
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception) at
System.Net.Mail.SmtpClient.Send(MailMessage message)
The strange thing is that the email box really exists.
My code is as follows:
1 ' Define user profile
2 Dim userProfile As ProfileCommon =
Profile.GetProfile(tbUsernameRecover.Text)
3
4 ' Define user name
5 Dim name As String = userProfile.Personal.Name
6
7 ' Define user email address
8 Dim email As String = user.Email
9
10 ' Reset user password
11 Dim newPassword As String = user.ResetPassword()
12
13 ' Create new mail message
14 Dim message As New System.Net.Mail.MailMessage
15
16 ' Define mail message properties
17 With message
18
19 ' Define mail message properties
20 .Body = Resources.Email.PasswordReset_Body & newPassword
21 .From = New
System.Net.Mail.MailAddress(ConfigurationManager.AppSettings("Email.NoReply.Address"),
ConfigurationManager.AppSettings("Email.NoReply.Name"))
22 .IsBodyHtml = False
23 .Subject = Resources.Email.PasswordReset_Subject
24 .To.Add(New System.Net.Mail.MailAddress(email, name))
25
26 End With
27
28 ' Create and define the SMTP client
29 Dim smtpClient As New System.Net.Mail.SmtpClient
30
31 ' Get mailSettings section from web.config
32 Dim mailSettings As
System.Net.Configuration.MailSettingsSectionGroup =
ConfigurationManager.GetSection("system.net/mailSettings")
33
34 ' Define smtp client properties
35 If Not mailSettings Is Nothing Then
36 With smtpClient
37 .Port = mailSettings.Smtp.Network.Port
38 .Host = mailSettings.Smtp.Network.Host
39 .Credentials = New
System.Net.NetworkCredential(mailSettings.Smtp.Network.UserName,
mailSettings.Smtp.Network.Password)
40 End With
41 End If
42
43 ' Send the mail message
44 Try
45
46 ' Send the mail message
47 smtpClient.Send(message)
48
49 Catch ex As Exception
50
51 Response.Write(ex.ToString)
52
53 End Try
And in my web.config file I have:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network defaultCredentials="true"
host="mail.mydomain.com" password="pass" port="25"
userName="(e-mail address removed)"/>
</smtp>
</mailSettings>
</system.net>
This email account exists and it is working!
Could someone tell me what am I doing wrong here?
Thanks,
Miguel