Exception of type 'System.Web.HttpUnhandledException' was thrown.
ERROR: Unable to Send Contact - 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. iq10sm53816480pbc.14 - gsmtp
protected void ImageButton_Submit_Click(object sender, ImageClickEventArgs e)
{
try
{
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress(HttpUtility.HtmlEncode(TextBoxEmail.Text));
mMailMessage.To.Add(new MailAddress("MyAccount@gmail.com"));
// mMailMessage.Bcc.Add(new MailAddress(bcc));
// mMailMessage.CC.Add(new MailAddress(cc));
mMailMessage.Subject = "From:" + HttpUtility.HtmlEncode(TextBoxYourName.Text) + "-" + HttpUtility.HtmlEncode(TextBoxSubject.Text);
mMailMessage.Body = HttpUtility.HtmlEncode(EditorEmailMessageBody.Content);
mMailMessage.IsBodyHtml = true;
mMailMessage.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.Send(mMailMessage);
LabelMessage.Text = "Thank You - Your Message was sent.";
}
catch (Exception exp)
{
throw new Exception("ERROR: Unable to Send Contact - " + exp.Message.ToString(), exp);
}
}
my web config code...
mailSettings
<smtp from="MyAccount@gmail.com">
<network host="smtp.gmail.com" password="MyAccountpassword" port="587">
userName="MyAccount@gmail.com"
</network></smtp>