My code for sending email through Gmail's smtp:
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("my_user_name", "my_password");
MailMessage message =
new MailMessage(new MailAddress("from...@gmail.com"), new MailAddress("to...@gmail.com"));
message.Body = "body";
message.Subject = "subject";
client.Send(message);
The code works on my local machine and when I publish at Azure as "Web Site".
BUT when I publish in a "Cloud Service" I get this exception:
System.Net.Mail.SmtpException: The SMTP server requires a secure connection
or the client was not authenticated. The server response was:
5.5.1 Authentication Required. Learn more at
Is there anything that differ a Windows Azure "Web site" from a "Cloud Service" that could have this effect?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…