Archived Forum Post

Index of archived forum posts

Question:

SendEmail Returns Success, but Recipient Never Receives Email

May 07 '15 at 06:49

I've had cases were SendEmail returns success, but the recipient never receives the email.


Answer

Your program connects to an SMTP server to send email. It is the SMTP client.
This is what the SMTP conversation looks like (S = server, C = client)

  S: 220 foo.com Simple Mail Transfer Service Ready
  C: EHLO bar.com
  S: 250-foo.com greets bar.com
  S: 250-8BITMIME
  S: 250-SIZE
  S: 250-DSN
  S: 250 HELP
  C: MAIL FROM:<Smith@bar.com>
  S: 250 OK
  C: RCPT TO:<Jones@foo.com>
  S: 250 OK
  C: DATA
  S: 354 Start mail input; end with <crlf>.<crlf>
  C: Blah blah blah...
  C: ...etc. etc. etc.
  C: .
  S: 250 OK
  C: QUIT
  S: 221 foo.com Service closing transmission channel
The "handoff" to the SMTP server is completed at the final "250 OK". At this point, the SMTP client-to-server transaction has been completed, and delivery is now in the hands of the SMTP server. Any problems occuring after the handoff are unknown to the SMTP client.

One common issue is that some SMTP servers will not actually initiate delivery until the connection is closed. Chilkat will by default keep the connection open to the SMTP server so that a subsequent call to SendEmail may use the already open and authenticated connection. An application may call mailman.CloseSmtpConnection to explicitly send the QUIT command, receive its response, and then cleanly disconnect from the SMTP server.