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?