Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
Debug / Verify SMTP Session
An SMTP client, such as the Chilkat Email component or Outlook, is responsible for passing an email to an SMTP server. Typically, the client connects to a single (i.e. your) SMTP server that acts as a relay to deliver email destined for a remote mail server. The "handoff" to your SMTP server is the 1st step in the mail delivery process. An SMTP client can only ensure that this handoff happens without error. After the handoff is complete, it is the SMTP server's job to relay the email to a remote SMTP server (or perhaps some intermediate server) to complete delivery. If the recipient indicates that he/she never received the email, the 1st step in debugging is to verify that the "handoff" happened without error. This is what this example is intended to demonstrate.
If there are no errors in the "handoff", then the non-delivery problem occurred downstream (i.e. at some point after your SMTP server accepted the email from you, the SMTP client). The most common cause for "non-delivery" is that the recipient's anti-SPAM filters rejected the email, or automatically placed it in his/her Junk email folder. Ask the recipient to check for that possibility.
If the recipient claims that anti-SPAM is not the cause, then you'll need to check your SMTP server's logs, and the recipient should check his/her mail server logs. Try to verify if your SMTP server successfully relayed the email. For the remote (receiving) mail server, try to see if the logs indicate that the mail was received. If so, was it rejected?
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% ' The interesting part of this example is near the bottom of this ' page where the SmtpSessionLog is captured and displayed. ' ' The mailman object is used for sending and receiving email. set mailman = Server.CreateObject("Chilkat.MailMan2") ' Any string argument automatically begins the 30-day trial. success = mailman.UnlockComponent("30-day trial") If (success <> 1) Then Response.Write "Component unlock failed" & "<br>" End If ' Set the SMTP server. mailman.SmtpHost = "smtp.chilkatsoft.com" ' Set the SMTP login/password (if required) mailman.SmtpUsername = "myLogin" mailman.SmtpPassword = "myPassword" ' Create a new email object set email = Server.CreateObject("Chilkat.Email2") email.Subject = "This is a test" email.Body = "This is a test" email.From = "Chilkat Support <firstname.lastname@example.org>" email.AddTo "Chilkat Gmail","email@example.com" email.AddTo "Chilkat Yahoo","firstname.lastname@example.org" ' Call SendEmail to connect to the SMTP server and send. ' The connection (i.e. session) to the SMTP server remains ' open so that subsequent SendEmail calls may use the ' same connection. success = mailman.SendEmail(email) If (success <> 1) Then Response.Write mailman.LastErrorText & "<br>" End If ' Some SMTP servers do not actually send the email until ' the connection is closed. In these cases, it is necessary to ' call CloseSmtpConnection for the mail to be sent. ' Most SMTP servers send the email immediately, and it is ' not required to close the connection. We'll close it here ' for the example: success = mailman.CloseSmtpConnection() If (success <> 1) Then Response.Write "Connection to SMTP server not closed cleanly." & "<br>" End If Response.Write Server.HTMLEncode( mailman.SmtpSessionLog) & "<br>" ' A sample SMTP session log is included below. ' There are two key items to verify: ' 1) Each recipient in the email (To, CC, BCC) should be present in the log ' in a "RCPT TO" command. You may visually verify that the response ' from the SMTP server was "250 OK" for each recipient. ' (Chilkat also provides a way to get the failed RCPT TO responses programmatically...) ' 2) The "DATA" command is followed by the client sending the full MIME source of the email, ' followed by a single line containing a ".". ' The final response from the SMTP server should be a "250 OK". ' If all of the RCPT TO commands were successful, and the final SMTP response was success, ' then the client-to-SMTP-server handoff was successful. If a delivery problem is reported by ' a recipient, the problem occurred downstream of this "handoff". ' 220 mail.chilkatsoft.com ESMTP 648143d3667b3045487bb901cdbbf649 ' 250-mail.chilkatsoft.com ' 250-PIPELINING ' 250-SIZE 100000000 ' 250-DATAZ ' 250-AUTH LOGIN PLAIN ' 250 8BITMIME ' AUTH LOGIN ' 334 xxxxxxxxxxxx ' 334 xxxxxxxxxxxx ' 235 nice to meet you ' MAIL FROM:<email@example.com> ' 250 ok ' RCPT TO:<firstname.lastname@example.org> ' 250 ok ' RCPT TO:<email@example.com> ' 250 ok ' DATA ' 354 go ahead ' MIME-Version: 1.0 ' Date: Wed, 19 Mar 2008 08:40:52 -0500 ' X-Mailer: Chilkat Software Inc (http://www.chilkatsoft.com) ' X-Priority: 3 (Normal) ' Subject: This is a test ' Content-Type: text/plain ' Content-Transfer-Encoding: quoted-printable ' From: "Chilkat Support" <firstname.lastname@example.org> ' To: "Chilkat Gmail" <email@example.com>, ' "Chilkat Yahoo" <firstname.lastname@example.org> ' Message-ID: <CHILKAT-MID-02039824-9296-78bb-fff7-88fe94e86148@CK2007> ' ' This is a test ' . ' 250 ok 1205934062 qp 28546 by mail.chilkatsoft.com %> </body> </html>
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.