我在Windows Azure应用程序上有一个smtp客户端,客户端在模拟器上正常工作,但在云实例。System.Net.Mail.SmtpException:SMTP服务器需要安全连接,或者客户端未在Azure上进行身份验证
异常消息是:
The SMTP server requires a secure connection or the client was not authenticated The server's response was 5.5.1 authentication required
我确信的凭据是通过在命令行打印他们的云是正确的,我还禁用了防火墙。
P.S:我使用gmail smtp服务器。
这里是我的代码:
private void SetupClient()
{
_emailSetting = new EmailSetting();
_smtpClient = new SmtpClient(_emailSetting.SMTP_Server, _emailSetting.Port);
_smtpClient.EnableSsl = true;
_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
_smtpClient.Credentials = new NetworkCredential(_emailSetting.EmailUser, _emailSetting.EmailPass);
}
public void Report(String msg)
{
MailMessage mailMessage;
if (_smtpClient == null)
{
SetupClient();
}
String receivers = String.Join(",", Receivers);
mailMessage = new MailMessage(_emailSetting.EmailUser, receivers, "Error", msg);
_smtpClient.Send(mailMessage);
}
需要更多详细信息,SMTP_Server和它的端口的值是什么?你通过什么格式的用户名? – Arran 2013-04-05 12:40:30
我试过gmail和live smtp,相信我这些设置都很好,因为它在我的本地机器上运行时会发送一封电子邮件,并且它会在云上打印相同的凭据。 – 2013-04-05 12:43:58