Unable to send mail (Mail Relay error), have all settings in SMTP Mail Server

Cannot send emails: How to fix email sending issues · Check your internet connection. · Check your SMTP server details. · Verify all usernames and passwords.

Unable to send mail (Mail Relay error), have all settings in SMTP Mail Server

If you do not want to have credentials in your configuration file, then you have to enable relay access in the SMTP service for the IP address instead. According to your screenshot, only authenticated connections are allowed to be relayed.

It usually helps to enable logging on the SMTP service so you can see exactly from where and how clients are trying to use the SMTP service.

I have done all the setting, I tried hit and trial, specified IP etc but still I am unable to send mail from my c# code (outside my domain, within its fine).

If I try to send mail by specifying credentials in web config, then I am able to send mails outside my domain. But that is not I want.

When I try to send via my code, then I do the setting on the SMTP , allow relay and specify domain, that doesn't work.

I check the checkbox, which states that send mail to all address etc. That is also not working.

Where I am wrong?

My code:

When I specify in web config:

<system.net>
<mailSettings>
  <smtp deliveryMethod="Network" from="abc@..com">
    <network enableSsl="false" host="hostname" port="25" userName="abc" password="abc#" defaultCredentials="false" clientDomain="domainname"/>
  </smtp>
</mailSettings>

When specifying through code:

using (smtp)
{
smtp.Host = "hostname";
smtp.UseDefaultCredentials = false;
smtp.Port = 25;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("abc@newgen.co.in", "abc123#");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
}

These settings in the server, but no success. enter image description here


Click Here to Visit

What's Your Reaction?

like
0
dislike
0
love
0
funny
0
angry
0
sad
0
wow
0