13
在Windows Azure中无法发送邮件这是我的web.config:C# - 通过Gmail SMTP
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network defaultCredentials="true" enableSsl="true" host="smtp.gmail.com" port="25" userName="[email protected]" 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.
InnerException:
Unable to connect to the remote server
我在本地测试它,但我想它应该工作。我必须在Windows Azure上运行它,我试过了,它也没有工作。有什么我失踪?
看到这样一个问题:http://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail/32336#32336 –