0
電子郵件在我的應用程序需要通過C#(使用Gmail或Hotmail)發送電子郵件 localhost上它的工作確定沒有錯誤,但在上傳到GoDaddy的託管所有的時間,我有錯誤,如C#錯誤使用Gmail或Hotmail
的Hotmail: 代碼:
SmtpClient SmtpServer = new SmtpClient("smtp-mail.outlook.com");
var mail = new MailMessage();
mail.From = new MailAddress("[email protected]");
mail.To.Add(ReciverMail);
mail.Subject = "Test Mail - 1";
mail.IsBodyHtml = true;
string htmlBody;
htmlBody = "Write some HTML code here";
mail.Body = htmlBody;
SmtpServer.Port = 587;
SmtpServer.UseDefaultCredentials = false;
SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "xxxxx");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
return "Mail has been successfully sent!";
的Gmail: 代碼:
MailMessage msg = new MailMessage();
msg.From = new MailAddress("xxx", "xxxx");
msg.Subject = "From ASU at " + DateTime.Now.ToString();
msg.To.Add(ReciverMail);
msg.Body = "Test";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Host = "smtp.gmail.com";
client.Port = 587;
client.EnableSsl = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new NetworkCredential("[email protected]", "xxxxx");
client.Timeout = 20000;
client.Send(msg);
return "Mail has been successfully sent!";
感謝您的快速回復:),我沒有找到任何與防火牆相關的選項,如果Plesk控制面板。 –