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 –