1

I am able to set up an IMAP/SMTP account in Outlook and subsequently send a test e-mail message with our internal Zentyal 4.2 server. Yet when I run the following code, it throws the SmtpException.

var smtpClient = new SmtpClient("xyz.com");
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential("my_account@xyz.com", "my_password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
// TEST only
ServicePointManager.ServerCertificateValidationCallback = 
    delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return true; };
// end of TEST only
smtpClient.Send("my_account@xyz.com", "user2@anotherserver.com", "test", "test");

Here's the exception message:

Client does not have permission to submit mail to this server. The server response was: 4.7.1 user2@anotherserver.com: Relay access denied.

What am I doing wrong?

Exulted
  • 373
  • 2
  • 5
  • 17
  • ask the server admins – pm100 Feb 28 '17 at 17:09
  • I already have. They sent me a screenshot of a successful connection via the iphone email app. – Exulted Feb 28 '17 at 17:25
  • 1
    Have you tried sending an email to your own domain name? See also http://stackoverflow.com/questions/7411273/throwing-exception-while-sending-email-to-multiple-recipients-using-smtp-client – Dan Field Mar 10 '17 at 19:11
  • I have tried your suggestion and now I get a different error, which is "5.5.2 : Helo command rejected: need fully-qualified hostname". Now I can go back my admins. Many thanks! – Exulted Mar 10 '17 at 20:20

0 Answers0