Reputation: 10400
I have this annoying issue:
When sending an email when debugging in VS, it works fine (I'm using SmtpClient
)
After publishing to the server, I get this error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: The remote name could not be resolved: 'mail.company.co.za'
However, if I change the smtp host to the IP address, it seems to work fine.
I got the IP by calling ping mail.company.co.za
in CMD (When calling this on the server it can't find the address, but it can ping the IP)
Since I'm not sure whether the IP is static or not, I don't know if its safe to just use the physical IP. Why would the server not recognise the mail.company.co.za
?
Note that I am debugging and hosting the application on the same network. This suggests to me that it is not a firewall issue, but maybe I'm wrong about that?
Upvotes: 0
Views: 768
Reputation: 3231
That sounds like your code is working properly, but you mailserver's DNS is not set up properly. Your PC can correctly look up the address, but the mailserver cannot.
Fixing this is a server admin question, not a coding question, but if you don't have IT people to do it for you, I suggest just finding the 'DNS Server' setting in your network setup and copying the settings from your PC to the server. Windows tends to change how you get to these settings with every version, but for me it's Control Panel / Network and Sharing / Ethernet / TCPIP / Properties
https://www.windowscentral.com/how-change-your-pcs-dns-settings-windows-10
Upvotes: 1