"SmtpFailedRecipientException: mailbox unreachable" when a mailbox is available

I get this error when I try to send an email to a specific address in my code:

System.Net.Mail.SmtpFailedRecipientException: The mailbox is unavailable. Server response: Unknown user

The code sends an email to two email addresses: my and my colleague. The email is sent to me in order, but I get this error when he tries to send him an email.

I looked around, and basically the general explanation for this error is that the email address is invalid or their mailbox is not allowed to receive mail, or there are some settings on the server that restrict it from receiving an email.

But the email address can receive email, I am responding back and forth via email with it right now.

Is there any other reason why this error may occur?

EDIT:

Here's the code, maybe someone can spot the problem. I checked the passed parameters, all data is correct:

private static void SendEmail(IEnumerable<MailAddress> to, MailAddress from, string subject, string body, string bodyHtml) { var mail = new MailMessage { From = from, Subject = subject }; foreach (var address in to) { mail.To.Add(address); } mail.AlternateViews.Add( AlternateView.CreateAlternateViewFromString(bodyHtml, null, "text/html")); mail.AlternateViews.Add( AlternateView.CreateAlternateViewFromString(body, null, "text/plain")); try { var smtp = new SmtpClient("localhost", 25) { Credentials = new NetworkCredential("xxx", "xxx") }; smtp.Send(mail); } catch (Exception err) { Elmah.ErrorSignal.FromCurrentContext().Raise(err); } } 
+4
source share
1 answer

Assuming your SMTP settings are correct, this is most likely a case of server-side restriction ...

For example, to prevent spam, the server only accepts smtp from the static IP sender and / or checks the sender's IP address for MX records (DNS), etc.

+7
source

All Articles