I ran into a strange problem the other day trying to send an email from code (C# using SmtpClient/MailMessage).
I was sending an email TO an external email address using our network’s SMTP relay.
I was authenticating, so the email should have gone through w/o a problem. The
code worked just fine for me, but whenever a contractor that works remotely ran it
on their system, the email wasn’t sent. There wasn’t even an exception to show
for it. Amusingly, with my internal email address in the CC, the CC made it,
but the external TO did not. I double checked the username/password. Tried
the IP address instead of the DNS name of the mail server. Finally on a hunch,
we added the “domain” parameter to the NetworkCredential that
was being created with our domain name. That finally fixed it.
Apparently, the way the Cisco VPN we have works is even though he was logging in using
domain credentials, the computer isn’t actually being joined to the domain, so the
code wasn’t seeing a domain name when it created the NetworkCredential.
I also would have assumed that since the SMTP relay knew about our domain, that would
have been the default domain it would have authenticated against, but apparently not.
