JustMe
JustMe

Reputation: 732

Relay access denied on sending email

I want to send email via my desktop app
Here is my code

        MailMessage m = new MailMessage("[email protected]", "[email protected]", "subject", "body");
        m.IsBodyHtml = true;
        SmtpClient smtp = new SmtpClient("out.tedata.net.eg");
        smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
        smtp.UseDefaultCredentials = true;
        smtp.Send(m);

My problem is: this code throw an exception

Transaction failed. The server response was: 5.7.1 <[email protected]>: Relay access denied

I think because my internet provider need outgoing server (SMTP) authentication I config it in Outlook as below enter image description here
Now, How can I config it in my code

Thanks

Upvotes: 1

Views: 8833

Answers (2)

Krunal Solanki
Krunal Solanki

Reputation: 541

It can be various issues:

  1. are you able to send mail to Yahoo mail from your outlook? check this link If yes
  2. Check IIS SMTP Virtual Server Relay Restrictions

Hope this help you.

Upvotes: 0

RobRdam
RobRdam

Reputation: 31

I found this question because I have the same problem. I solved it using the myNetworks entry in /etc/postfix/main.cf Add the IP from which your sending to the myNetworks line, I think PostFix expects a space to separate IP adresses, for my eyes it's better to use a comma, but if I use both it works.

This solution is not ideal, so I'll be gratefull for a better one!

Rob

Upvotes: 0

Related Questions