![](/img/trans.png)
[英]I cannot send mail with SwiftMailer or PHPMailer from Localhost using gmail
[英]Cannot send mail from an Azure VM using Gmail
我正在嘗試使用Gmail從asp.net webform發送電子郵件。 代碼可以從我的機器上運行但是當我將代碼上傳到Azure中的Windows Server 2012時,我無法連接到遠程服務器 - 異常
這是我的代碼:
MailMessage mail = new MailMessage();
mail.Subject = "Subject";
mail.Body = "Main body goes here";
mail.From = new MailAddress("myAcount@gmail.com");
mail.IsBodyHtml = true;
mail.BodyEncoding = System.Text.Encoding.Unicode;
mail.SubjectEncoding = System.Text.Encoding.Unicode;
mail.To.Add("aaaa@gmail.com");
NetworkCredential cred = new NetworkCredential("myAccount@gmail.com", "myPwd");
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mail);
有任何想法嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.