【发布时间】:2013-07-02 00:10:11
【问题描述】:
我正在尝试使用 gmail 发送邮件,但我收到了一个异常 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. i16sm1806350pag.18 - gsmtp
我为发送邮件编写的代码是:
MailMessage mail = new MailMessage();
mail.To.Add(txtEmail.Text.Trim());
mail.To.Add("Secondry@gmail.com");
mail.From = new MailAddress("mysendingmail@gmail.com");
mail.Subject = "Confirmation of Registration on Job Junction.";
string Body = "Hi, this mail is to test sending mail using Gmail in ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
// smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential("mysendingmail@gmail.com", "password");
// smtp.Port = 587;
//Or your Smtp Email ID and Password
smtp.UseDefaultCredentials = false;
// smtp.EnableSsl = true;
smtp.Send(mail);
请告诉我解决方案,我没有针对此异常的任何解决方案。
【问题讨论】:
-
您好@Ankur,如果您解决了您的问题,请帮助我,因为我遇到了同样的错误。
-
-
@AnkurGupta - 请详细解释一下如何操作。谢谢!