我已经阅读了stackoverflow上的其他答案,但是没有一个解决方案适用于我。
我正在尝试通过live.com发送电子邮件,但无法成功。
错误信息:
mailbox unavailable. The server response was: 5.7.3 requested action aborted;
user not authenticated
或错误消息:
System.Net.Mail.SmtpException: Service not available,
closing transmission channel.
The server response was: Cannot connect to SMTP server 65.55.176.126
(65.55.176.126:587), NB connect error 1460
代码如下:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("email@live.com");
mail.To.Add("someone@someone.com");
mail.Subject = "hello";
mail.Body = "awefkljj kawefl";
mail.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("email@live.com", "password");
smtp.Send(mail);
您能使用以上代码发送电子邮件吗?
该代码以前可以使用,但现在不再起作用。
我不确定live.com电子邮件服务器所做的更改。
应该应用哪些新设置或参数?
MailMessage
和SmtpClient
放入using
块中:using (MailMessage mail = new MailMessage()){... using (SmtpClient smtp = new SmtpClient("smtp.live.com", 587)){...}}
- John Saunders