Unable to send emails to external domain using SMTP Unable to send emails to external domain using SMTP asp.net asp.net

Unable to send emails to external domain using SMTP


I had this issue and authenticating fixed it see below:

SmtpClient client = new SmtpClient(EmailServer, 25);var SmtpUser = new System.Net.NetworkCredential("domain\\username", "password");client.Credentials = SmtpUser;client.DeliveryMethod = SmtpDeliveryMethod.Network;

I had to use the double slash since one slash is the escape character so use two for it to work.


If you were to look up the MX record for the destination address (in your example, it is asdf.com) and then use that for the host property of SmtpClient, it should accept the message for delivery without authentication since it's to a local user. This is not easy to do since System.Net doesn't provide a managed DNS class that can return MX records but you can P/invoke unmanaged code to do it. Otherwise you will need to be sure that whatever SMTP server you are connecting to will relay for you and then set the Credentials property of SmtpClient to the appropriate credentials for connecting to that server. Setting the DeliveryMethod to PickupDirectoryFromIIS still only writes a file to the IIS pickup directory so it's only writing a file, it isn't doing an actual send.


You usually need to authenticate with the external mail server using a username/password. As you are using an external server this will not know the credentials you are passing. This may be your issue.