Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relay access denied 5.7.1

I've got the error "Relay access denied", but I can connect my account with some email programs.

My code:

        SmtpClient smtpClient = new SmtpClient();
        NetworkCredential basicCredential =
            new NetworkCredential("[email protected]", "xxx");
        MailMessage message = new MailMessage();
        MailAddress fromAddress = new MailAddress("[email protected]");

        smtpClient.Host = "mail.xx.com";
        smtpClient.Port = 587;
        smtpClient.UseDefaultCredentials = false;
        smtpClient.Credentials = basicCredential;

        message.From = fromAddress;
        message.Subject = subject;
        message.IsBodyHtml = true;
        message.Body = body;
        message.To.Add("[email protected]");

        try    
        {
            smtpClient.Send(message);
        }
        catch (Exception ex)
        {
            //Relay access denied...
        }

Does anyone know the reason for this?

like image 217
Mustafa KIRILMAZ Avatar asked Dec 08 '13 14:12

Mustafa KIRILMAZ


People also ask

How do I fix relaying denied?

You must be authorized to use a mail server for relaying. Unauthorized users will always receive the "Relaying Denied" error. To use a mail server, you must prove to the mail server that you are authorized to send email. By far the most common cause is that no user name and password were specified.

How do I fix 554 5.7 1 VI blocked message due to spam content in the message?

That error message means the message has been rejected by the recipient's domain (the receiving end), and so, your outgoing SMTP server failed to deliver it. This is not something you can fix from your end as the sender.

What does Relay Access Denied mean?

This means that you are trying to send the mail from an outgoing mail server (SMTP) other than the one that is associated to your mailbox, and that the outgoing mail server does not allow such an action.

What does 550 5.7 relaying denied mean?

It's likely that the server isn't set up correctly to receive and relay messages sent from <Microsoft _365_domain>..." This issue can occur if connectors have been enabled in the Microsoft 365 domain's Exchange Online, 'mail flow' settings and those connectors are either no longer active or are faulty.


2 Answers

Since your smtp host port is 587, I think you should set smtpClient.EnableSsl to true before calling its Send method.

like image 179
Yong Tiger Avatar answered Sep 18 '22 11:09

Yong Tiger


Although this question is almost a year old now, I just stumbled upon the solution to a similar problem today. Apparently, the System.Net.Mail.SmtpClient class does not support the AUTH PLAIN method. Unfortunately, the SMTP server I was trying to use only offered AUTH PLAIN. Since the SmtpClient class and my server couldn't agree on an authentication method, the SmtpClient tried to send mails without authentication which got rejected by the SMTP server...

You should make sure that the SMTP server you are using offers at least one of the authentication mechanisms that SmtpClient supports. I couldn't find an exhaustive list of supported mechanisms but my server is now offering AUTH LOGIN which works with SmtpClient.

like image 45
PoByBolek Avatar answered Sep 19 '22 11:09

PoByBolek