我收到了错误“服务器不支持安全连接”与我的代码如下。服务器不支持在C#中的安全连接
SmtpClient smtp = new SmtpClient();
MailMessage mail = new MailMessage();
mail.From = new MailAddress("*****@gmail.com");
mail.To.Add(recieverId);
mail.Subject = "Invoice Copy and Delivery Confirmation for booksap.com Order " + orderno + ". Please Share Feedback.";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(Server.MapPath("OrderMail\\Invoice.pdf"));
mail.Attachments.Add(attachment);
MailBody = "We are pleased to inform that the following items in your order " + orderno + " have been placed. This completes your order. Thank you for shopping! ";
StreamReader reader = new StreamReader(Server.MapPath("~/MailHTMLPage.htm"));
string readFile = reader.ReadToEnd();
string myString = "";
myString = readFile;
myString = myString.Replace("$$Name$$", ContactPersonName);
myString = myString.Replace("$$MailBody$$", MailBody);
mail.Body = myString.ToString();
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("*******@gmail.com", "*******");
smtp.Send(mail);
mail.Dispose();
mail = null;
我该如何解决这个问题? 如果我设置
EnabledSsl = false
它会返回错误:SMTP服务器要求安全连接或客户端未通过身份验证。服务器响应是:5.7.1客户端未通过身份验证。
我认为Gmail的SMTP是不工作的少安全连接。刚刚尝试过sendgrid或搜索其他电子邮件服务 –
好吧,先生,我会尽力回复给你。 – Abhishek