Alex Zhukovskiy
Alex Zhukovskiy

Reputation: 10025

Anonymous mail sending: Relay access denied

I have a SQL Server, and it's sending some e-mails. But now I'm sending them from code and should rewrite this functionality in code. But have no success getting

An exception of type 'System.Net.Mail.SmtpException' occurred in System.dll but was not handled in user code

Additional information: Transaction failed. The server response was: 5.7.1 : Relay access denied

Please advice, what am I doing wrong?

SQL Server mail setup:

enter image description here

Code mailing:

var smtp = new SmtpClient("15.15.15.15", 25);
smtp.Send("[email protected]", addressOfPhone, "subj", "body");

Upvotes: 0

Views: 2691

Answers (1)

Fred
Fred

Reputation: 5808

The server you are trying to send the mail through is set up to deny anonymous users sending mail (as most are, to prevent spammers for example). It may be that you need to authenticate first, probably using the basic authentication.

Upvotes: 3

Related Questions