C# sending email code suddenly stopped working
-
31-10-2019 - |
题
i have the following code that has worked fine for months but suddently stopped working on this line:
smtpClient.Send(msg);
this is an internal application sending emails to internal people in my company
with the following error:
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for ABC@comp.com
can anyone think of a reason why this code would work fine for ages and suddently just stop work ?
MailMessage msg = new MailMessage();
msg.From = new MailAddress(fromEmailAddress_);
msg.IsBodyHtml = true;
msg.To.Add(new MailAddress(email.Trim()));
msg.Subject = subject_;
msg.Body = body_;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
var smtpClient = new SmtpClient(_mailServer);
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(_user, _pwd);
try
{
smtpClient.Send(msg);
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
没有正确的解决方案
不隶属于 StackOverflow