saranya
saranya

Reputation: 11

MailBox UnAvailable 5.7.1. The server response was: 5.7.1 Unable to relay

Below code is working fine if I send mails which are in xyz.rw domain (like [email protected], [email protected]). When I tried to send mail to my gmail account, below error occurred. Its not working for other domain mail ids

MailBox Unavailable 5.7.1. The server response was: 5.7.1 Unable to relay

Please let me know how to fix this.

SmtpClient smtp = new SmtpClient();
smtp.Port = 25;
smtp.Host = "10.8.12.242";
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential(senderID, senderPassword);
smtp.Timeout = 30000;

MailMessage message = new MailMessage(senderID, "[email protected]", "Information Entreprise", "Hello, that message has been sent as consiquence of mail sending test.");
try
{
    smtp.Send(message);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

Upvotes: 0

Views: 14681

Answers (2)

ronnyfch
ronnyfch

Reputation: 1

in my case, the solution is set the access - connection control - connection : "all except the list below" access - relay restriction - relay : "all except the list below" security - add domain users

and remember to set the firewall setting to allow port 25 outbound

Upvotes: 0

Amirhossein Mehrvarzi
Amirhossein Mehrvarzi

Reputation: 18944

550 5.7.1 Unable to Relay’ code error generally occurs when the user tries to send emails outside his domain.

Causes for the error:

  1. The outgoing mail server could not identify the sender.
  2. There are some issues while authenticating the sender on the server and thus restricting them to send emails.
  3. The receiver domain’s recipient policy has imposed restrictions on the sender’s domain / department. The Exchange Database is corrupt.
  4. A properly configured mail server is extremely restrictive with relaying, to prevent it from being abused by spammers to send mails.

So, That's a config issue in the mail servier. It doesn't allow you (your IP, your sender address) to send mail to the recipient.

Solution : you need to add the address to IIS Manager. Goto IIS Manager -> Default SMTP Server -> Properties -> Access -> Relay -> allow only from the list below -> add -> 'Address Here' -> Click OK

Upvotes: 3

Related Questions