Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'5.7.1 Client does not have permission' error while sending email from code

So I have this very basic program that is trying to send an e-mail, but I keep getting

Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender

Here is my program

static void Main(string[] args)
{
    SmtpClient client = new SmtpClient("Server", 25);
    client.UseDefaultCredentials = false;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.Credentials = new NetworkCredential("UserName", "Password");
    client.Send(new MailMessage("[email protected]","Recipient"));
}

I know the credentials work, if I run SMTP Test Tool 3.0 with the same data everything works great.

enter image description here

Here is some screen shots on a receive connector set up for my IP on the exchange server

enter image description here

enter image description here

Anybody have any ideas what would be causing this error in my code, but not within the simple SMTP testing tool? Am I missing some kind of authentication option somewhere? I have quadruple checked all the information is correct and identical in both places and it works in the tool but not in the code.

like image 278
Kevin DiTraglia Avatar asked Aug 22 '12 20:08

Kevin DiTraglia


People also ask

What is status code 5. 7 1?

You might see this error if: You don't have permission to send to the recipient. You don't have permission to send to the distribution group or subgroups. You don't have permission to send email through an email server that's between you and the recipient. Your message was routed to the wrong email server.


1 Answers

I found the problem, I needed to check the box 'Accept any sender' for authenticated users.

enter image description here

More information here: http://technet.microsoft.com/en-us/library/aa997170(EXCHG.140).aspx

like image 164
Kevin DiTraglia Avatar answered Sep 20 '22 12:09

Kevin DiTraglia