Hello
Got Error while tried to send email through smtp
my code is >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Protected Sub Submitbutton_Click(sender As Object, e As System.EventArgs) Handles Submitbutton.Click
Dim EMail1 As New MailMessage
EMail1.From = New MailAddress("Receiver")
EMail1.[To].Add(New MailAddress("Sender"))
EMail1.Subject = Firstnametextbox.Text + lastnametextbox.Text + "Register "
EMail1.Body = " This is content "
EMail1.IsBodyHtml = True
Dim mailclient As New SmtpClient
mailclient.Send(EMail1)
EMail1.Dispose()
End Sub
Email seeting in web.config file ::>>>>>>>>>>>>>>>>>>>>
<!-- EMAIL SETTINGS -->
<system.net>
<mailSettings>
<smtp>
<network host="servername" port="25"/>
</smtp>
</mailSettings>
</system.net>
error ::>>>>>
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
Source Error:
Line 13: EMail1.IsBodyHtml = True
Line 14: Dim mailclient As New SmtpClient
Line 15: mailclient.Send(EMail1) Line 16:
Line 17: EMail1.Dispose()
|
Stack Trace:
[SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated]
System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) +1210339
System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) +41
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +97
System.Net.Mail.SmtpClient.Send(MailMessage message) +1772
RegistrationToolforOnlineCourses_RegisterationForm.Submitbutton_Click(Object sender, EventArgs e) in C:\projects\New\RegisterationForm.aspx.vb:15
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563