此代码在本地工作,但是当我将其上传到 Godaddy 上的服务器时,它不会发送电子邮件。知道为什么它在他们的服务器上不起作用吗?我需要改变什么?
try {
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("Myemail@gmail.com");
mail.To.Add("Myemail@gmail.com");
mail.Subject = "New sign up";
mail.Body = "New member";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("Myemail@gmail.com", "**Mypass**");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
} catch(Exception ex) {
throw ex;
}