我有几个网站,我使用 smtp 客户端发送邮件。直到今天,一切正常,但是当我调试任何站点并尝试发送邮件时,突然出现超时错误。如果我发布我的网站并尝试从中发送电子邮件,它工作正常???
SmtpClient mySmtpClient = new SmtpClient("mail.ACCOUNT.co.za");
// set smtp-client with basicAuthentication
mySmtpClient.UseDefaultCredentials = false;
System.Net.NetworkCredential basicAuthenticationInfo = new
System.Net.NetworkCredential("ACCOUNTNAME", "PASSWORD");
mySmtpClient.Credentials = basicAuthenticationInfo;
// add from,to mailaddresses
MailAddress from = new MailAddress("ACCOUNTEMAIL");
MailAddress to = new MailAddress("EMAILADDRESS");
MailMessage myMail = new System.Net.Mail.MailMessage(from, to);
// add ReplyTo
MailAddress replyto = new MailAddress("EMAILADDRESS");
myMail.ReplyTo = replyto;
// set subject and encoding
myMail.Subject = "Password Request";
myMail.SubjectEncoding = System.Text.Encoding.UTF8;
// set body-message and encoding
myMail.Body = "MESSAGE";
myMail.BodyEncoding = System.Text.Encoding.UTF8;
// text or html
myMail.IsBodyHtml = true;
mySmtpClient.Send(myMail);
昨天它工作正常,我没有改变任何东西。