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.