我通过 Gmail 的 smtp 发送电子邮件的代码:
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("my_user_name", "my_password");
MailMessage message =
new MailMessage(new MailAddress("from...@gmail.com"), new MailAddress("to...@gmail.com"));
message.Body = "body";
message.Subject = "subject";
client.Send(message);
该代码适用于我的本地计算机,并且当我在 Azure 上作为“网站”发布时。
但是当我在“云服务”中发布时,我得到了这个例外:
System.Net.Mail.SmtpException: The SMTP server requires a secure connection
or the client was not authenticated. The server response was:
5.5.1 Authentication Required. Learn more at
Windows Azure“网站”与“云服务”有什么不同会产生这种效果吗?
谢谢!