C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

C# Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

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?

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

//  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.
Chilkat.MailMan mailman = new Chilkat.MailMan();

//  Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    MessageBox.Show("Component unlock failed");
    return;
}

//  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
Chilkat.Email email = new Chilkat.Email();

email.Subject = "This is a test";
email.Body = "This is a test";
email.From = "Chilkat Support <support@chilkatsoft.com>";
email.AddTo("Chilkat Gmail","chilkat.support@gmail.com");
email.AddTo("Chilkat Yahoo","chilkat_software@yahoo.com");

//  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 != true) {
    MessageBox.Show(mailman.LastErrorText);
    return;
}

//  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 != true) {
    MessageBox.Show("Connection to SMTP server not closed cleanly.");
}

textBox1.Text += mailman.SmtpSessionLog + "\r\n";

//  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:<support@chilkatsoft.com>
//  250 ok
//  RCPT TO:<chilkat.support@gmail.com>
//  250 ok
//  RCPT TO:<chilkat_software@yahoo.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" <support@chilkatsoft.com>
//  To: "Chilkat Gmail" <chilkat.support@gmail.com>,
//           "Chilkat Yahoo" <chilkat_software@yahoo.com>
//  Message-ID: <CHILKAT-MID-02039824-9296-78bb-fff7-88fe94e86148@CK2007>
// 
//  This is a test
//  .
//  250 ok 1205934062 qp 28546 by mail.chilkatsoft.com

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Email Component · XML Parser