Darkwingduck
Darkwingduck

Reputation: 133

SMTP shows success, but email never is delivered C#

Okay so I have this code that sends emails when someone signs up for my website. The emails send just fine to a gmail account or my work account, but doesnt show up in my hotmail account or an outlook account. I contacted the people who run the SMTP server I am using and they say their logs show the email is sent without a problem. I even had a buddy create a test application using my exact code, and his email sent and showed up just fine. Does anyone have any guesses as to why the emails would work for gmail, but maybe doesn't show up in hotmail, even though our server shows that they were successfully sent?

I have looked all over and can't seem to find a solution, or even someone having the same problem.

Edit: I have checked in the junk/spam folder. They dont show up there either.

Upvotes: 4

Views: 8138

Answers (1)

Thoryn Hawley
Thoryn Hawley

Reputation: 363

Even as a consultant working on this exact kind of problem for clients over the last 22 years I don't have an easy answer for your problem, but perhaps I can point you in the right direction.

The way a piece of mail gets from the client to the destination is a long chain of mail servers. You can see the chain of servers if you look at the message headers.

  1. Sender's mail client
  2. Sender's mail server
  3. 0+ Additional mail servers/gateways on sending side
  4. Recipient's upstream provider (optional) (maybe passive)
  5. Recipient's spam filter server
  6. Recipient's mail gateway (sometimes combined with 5 or 7)
  7. Recipient's mail server
  8. Recipient's mail client

Every one of these servers will have rules that filter messages. These can be based on many different things (client IP, sending server IP, sender domain, black lists, etc.)

What I suspect is happening is this:

  1. Client sends to server - OK
  2. Sending server sends (maybe through other servers) to Hotmail gateway - OK
  3. Hotmail gateway queues message for scanning
  4. Scanner scans message, and throws it away for some reason.
  5. Your code thinks it was OK because it got an OK from the local server.

So, what can we do about this? A couple more tests:

  1. Try filling out more fields on the MailMessage object. Some spam scanners are picky about empty fields. In particular fill in the ReplyToList (just use the same as the From). Ensure that all fields are not null/empty (check in debugger).

  2. I assume you are currently sending from your development machine? If so, try to get a different IP address for it. This is pretty easy if it is a laptop. Switch from wired to wireless, or vice versa. In a pinch, you can borrow someone's USB->Ethernet adapter. This will change the source IP address in the header and alter how the message is scanned.

  3. Send a message to Hotmail from a normal mail client on the same machine your code is sending from. Make sure to use the same outgoing server/username/password. If it gets delivered, look at the header to see what you can figure out. Compare it to the header of your mail message that was received at gmail. If it doesn't, at least you can positively rule out your code.

  4. Try sending mail from Hotmail to your server. The path may not be exactly the same, but again, the headers may have clues for you.

  5. If you have access to the sending mail server logs, there may be clues there too.

  6. If you get desperate, use a different outgoing mail server.

Upvotes: 3

Related Questions