【发布时间】:2011-09-26 18:20:36
【问题描述】:
这是我的 Web.config:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network defaultCredentials="true" enableSsl="true" host="smtp.gmail.com" port="25" userName="xxxxxxx@gmail.com" password="xxxxxxxxxxx"/>
</smtp>
</mailSettings>
</system.net>
我的方法:
public static void EmailVerification(string email, string nickname)
{
MailAddress from = new MailAddress("xxxxxxxxxxx", "xxxxxxxxxxxx");
MailAddress to = new MailAddress(email);
MailMessage message = new MailMessage(from, to);
message.Subject = "Test";
message.Body = "Test";
SmtpClient client = new SmtpClient();
try
{
client.Send(message);
}
catch(SmtpFailedRecipientException ex)
{
HttpContext.Current.Response.Write(ex.Message);
return;
}
}
我的失败 SmtpException:
Failure sending mail.
内部异常:
Unable to connect to the remote server
我正在本地测试它,但我想它应该可以工作。我必须在 Windows Azure 上运行它,我试过了,但也没有用。我有什么遗漏吗?
【问题讨论】:
标签: azure smtpclient