Đây là Web.config của tôi:C# - Không thể gửi mail trong Windows Azure qua 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>
phương pháp của tôi:
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;
}
}
thất bại của tôi SmtpException:
Failure sending mail.
InnerException:
Unable to connect to the remote server
Tôi đang thử nghiệm tại địa phương nhưng tôi đoán nó sẽ hoạt động. Tôi phải chạy nó trên Windows Azure, tôi đã cố gắng và nó đã không làm việc quá. Có cái gì tôi đang mất tích?
thấy câu hỏi này: http://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail/32336#32336 –