I have created a simple form using Visual Studio 2012 but it's not sending email to my gmail account, the page runs fine but when I hit send button I get error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. j8sm1567623paz.30
Description: An unhanded 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.0 Must issue a STARTTLS command first. j8sm1567623paz.30
Source Error:
Line 14:
Line 15:
Line 16: mailClient.Send(message)
Line 17:
Line 18:
Source File: C:\Website SVN II\test\contact.aspx.vb Line: 16
Sources:
Imports System.Net.Mail
Partial Class contact
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
sendMail(txtEmail.Text, txtMessage.Text)
End Sub
Protected Sub sendMail(ByVal From As String, ByVal body As String)
Dim mailservername As String = "smtp.gmail.com"
Dim message As MailMessage = New MailMessage(From, "nabeel.f@gmail.com", "feedback", body)
Dim mailClient As SmtpClient = New SmtpClient
mailClient.Host = mailservername
mailClient.Send(message)
message.Dispose()
End Sub
End Class
HTML.
first name
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
<br />
<br />
last name
<asp:TextBox ID="txtLName" runat="server"></asp:TextBox>
<br />
<br />
email
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<br />
<br />
message:
<asp:TextBox ID="txtMessage" runat="server" TextMode="MultiLine"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Send" />