此代碼在本地工作,但是當我將它上傳到Godaddy上的服務器時,它不會發送電子郵件。任何想法,爲什麼它不能在他們的服務器上工作?我需要改變什麼?發送郵件在本地工作,但不在服務器上?
try {
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "New sign up";
mail.Body = "New member";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "**Mypass**");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
} catch(Exception ex) {
throw ex;
}
你捕獲異常? – xxpor 2011-12-19 01:24:00