TSmtpCli
Last Updated: 09/29/2001

TSmtpCli class implements the SMTP protocol (RFC-821) used to send e-mail.

This component, combined with the TPop3Cli component form the basis of an e-mail client.

Here are the sections available for the TSmtpCli:


Below is the full description for all the sections in the TSmtpCli:

[Properties]

Below is a list of all Properties for use as a quick reference:

[Back to Main]



Below is a list of all Properties with their complete descriptions:

AuthType:  property AuthType: TSmtpAuthType;

 Specifies what type of SMTP authentication will be used. The default value is smtpAuthNone (no authentication). This property is used by the Auth() method. The supported authentication types are: smtpAuthNone, smtpAuthPlain, smtpAuthLogin, smtpAuthCramMD5.

[Return to Top]
 
CharSet:  property CharSet: String;

 Specifies what character set will be used in the mail message. This is a compliment to the ContentType property. The default is ISO-8859-1.

[Return to Top]
 
Connected:  property Connected: Boolean;

 Specifies if there is currently an active connection to the SMTP server.

[Return to Top]
 
ContentType:  property ContentType: TSmtpContentType;

 Specifies the MIME-type of the content within the message. It can be either smtpPlainText (MIME-Type text/plain) or smtpHTML (MIME-Type text/html). The default is smtpPlainText (text/plain).

 If you change this property after calling the component constructor, you must call the SetContentType() method.

[Return to Top]
 
EmailFiles:  property EmailFiles: TStrings;

 Specifies a list of filenames to be sent as MIME attachments with the e-mail.

[Return to Top]
 
ErrorMessage:  property ErrorMessage: String;

 Contains the string of the last error that occurred.

[Return to Top]
 
FromName:  property FromName: String;

 Specifies the e-mail address of the sender. This property will be used for the e-mail envelope (required by the SMTP server) and it will not be included in the message headers. This is the e-mail address to which the server will return the message if it could not be delivered.

[Return to Top]
 
HdrFrom:  property HdrFrom: String;

 Specifies the 'From:' header of the message. This is the address that the recipient will see as the sender.

 Note: For more information about the message headers, refer to RFC-822.

[Return to Top]
 
HdrReplyTo:  property HdrReplyTo: String;

 Specifies the 'Reply-To:' header of the message. This is the address to which replies by the recipient(s) will be sent.

 Note: For more information about the message headers, refer to RFC-822.

[Return to Top]
 
HdrReturnPath:  property HdrReturnPath: String;

 Specifies the 'Return-Path:' header of the message. This header is supposed to be added by the final transport system that delivers the e-mail and is intended to identify a path back to the sender in case of problems. Do not confuse this with the 'Reply-To:' header which is intended to direct replies.

 Note: For more information about the message headers, refer to RFC-822.

[Return to Top]
 
HdrSender:  property HdrSender: String;

 Specifies the 'Sender:' header of the message. It is intended for use when the sender is not the author of the message. The default is the string specified in the HdrFrom property.

 Note: For more information about the message headers, refer to RFC-822.

[Return to Top]
 
HdrSubject:  property HdrSubject: String;

 Specifies the 'Subject:' header of the message.

 Note: For more information about the message headers, refer to RFC-822.

[Return to Top]
 
HdrTo:  property HdrTo: String;

 Specifies the 'To:' header of the message. It is not necessarily the recipient of the message.

 Note: For more information about the message headers, refer to RFC-822.

[Return to Top]
 
Host:  property Host: String;

 The SMTP Server to which you want to connect.

[Return to Top]
 
LastResponse:  property LastResponse: String;

 The server response from the most recent command request.

[Return to Top]
 
LocalAddr:  property LocalAddr: String;

 Can be a dotted IP address, or a hostname. Preferable is a dotted IP address. For a client it is the machine to connect to, and for a server it is the interface to listen on if it is a multihomed computer. Default value for a server is '0.0.0.0'.

[Return to Top]
 
MailMessage:  property MailMessage: TStrings;

 Specifies the body of the e-mail message.

[Return to Top]
 
OwnHeaders:  property OwnHeaders: Boolean;

 This property indicates whether the message contains its own set of headers. If OwnHeaders is set to True, the component will not add any headers to the message when sending. This is useful for relaying e-mail between SMTP servers, where the message itself already contains its own headers.

[Return to Top]
 
Password:  property Password: String;

 The password used to authenticate with the SMTP server. This property is used by the Auth() method.

[Return to Top]
 
Port:  property Port: String;

 The tcp port of the SMTP server to which you want to connect. The default is 'smtp'.

[Return to Top]
 
RcptName:  property RcptName: TStrings;

 Specifies a list of e-mail addresses to which the message will be delivered. This property will be used for the e-mail envelope (required by the SMTP server) and represents the actual recipient(s) of the message. None of the addresses in this list will be included in the message headers.

[Return to Top]
 
SignOn:  property SignOn: String;

 Specifies the domain of the sender, required by the SMTP server for identification in order to start an SMTP session. This property is used by the Helo() and Ehlo() methods.

[Return to Top]
 
State:  property State: TSmtpState;

 The current state of the component. It can be any of the following: smtpReady, smtpDnsLookup, smtpConnecting, smtpConnected, smtpInternalReady, smtpWaitingBanner, smtpWaitingResponse, smtpAbort.

[Return to Top]
 
Username:  property Username: String;

 The Username used to authenticate with the SMTP server. This property is used by the Auth() method.

[Return to Top]
 

[Events]

Below is a list of all Events for use as a quick reference:

[Back to Main]



Below is a list of all Events with their complete descriptions:

OnAttachContentType:  property OnAttachContentType: TSmtpAttachmentContentType;

 When the Data() method is called and the message contains file attachments, this event is fired before each file is attached (when the MIME headers are sent).

[Return to Top]
 
OnAttachHeader:  property OnAttachHeader: TSmtpAttachHeader;

 When the Data() method is called and the message contains file attachments, this event is fired after the MIME headers for each file is sent.

[Return to Top]
 
OnCommand:  property OnCommand: TSmtpDisplay;

 This event is fired right after an SMTP command is sent to the server.

[Return to Top]
 
OnDisplay:  property OnDisplay: TSmtpDisplay;

 This event is fired whenever a command is sent or a response is received. This is mainly used to trace or log the SMTP transaction with the server while debugging.

[Return to Top]
 
OnGetData:  property OnGetData: TSmtpGetDataEvent;

 When the Data() method is called, this event is fired before sending each line of the message body, including the headers.

[Return to Top]
 
OnHeaderLine:  property OnHeaderLine: TSmtpHeaderLineEvent;

 When the Data() method is called, this event is fired after each header line is sent to the SMTP server. This is useful to intercept the headers and add your own.

[Return to Top]
 
OnProcessHeader:  property OnProcessHeader: TSmtpProcessHeaderEvent;

 When the Data() method is called, this event is fired when all the headers have been sent to the server.

[Return to Top]
 
OnRequestDone:  property OnRequestDone: TSmtpRequestDone;

 This event is fired after a request to the SMTP server has finished and a response has been received, even if the request failed.

[Return to Top]
 
OnResponse:  property OnResponse: TSmtpDisplay;

 This event is fired every time a response is received from the SMTP server as a consequence to an SMTP command.

[Return to Top]
 
OnSessionClosed:  property OnSessionClosed: TSessionClosed;

 This event is fired when the SMTP session is closed and the connection to the server is dropped due to a Quit() or Abort() method call.

[Return to Top]
 
OnSessionConnected:  property OnSessionConnected: TSessionConnected;

 This event is fired when a connection to the SMTP server is established and the SMTP session starts after a Connect() or Open() method call (when the welcome banner is received). In the case of the Open() method, OnSessionConnected is fired after the connection is established but before the HELO/EHLO command is sent.

[Return to Top]
 

[Methods]

Below is a list of all Methods for use as a quick reference:

[Back to Main]



Below is a list of all Methods with their complete descriptions:

Abort:  procedure Abort;

 Aborts the current operation and closes the connection. This is a quick and dirty way of closing an SMTP session.

[Return to Top]
 
Auth:  procedure Auth;

 Attempts server authentication using the authentication type specified in the AuthType property. This method requires that you sign on to the server by calling Ehlo() instead of Helo().

[Return to Top]
 
Connect:  procedure Connect;

 Connects to the SMTP server.

[Return to Top]
 
Data:  procedure Data;

 Submits the message to the SMTP server, including all headers. If the EmailFiles property contains any filenames, they are first encoded using Base64 and sent along with the message.

[Return to Top]
 
Ehlo:  procedure Ehlo;

 Alternative to the Helo() method for signing on to the SMTP server. This method sends the domain specified in the SignOn property and starts an Extended SMTP (ESMTP) session. If the server supports ESMTP, it will reply with a list of the extensions it supports.
[Return to Top]
 
Helo:  procedure Helo;

 Signs on to the SMTP server to start the SMTP session. This method sends the domain specified in the SignOn property.

[Return to Top]
 
HighLevelAsync:  procedure HighLevelAsync(RqType: TSmtpRequest; Fcts: TSmtpFctSet);

 Provides a high level interface to execute a set of SMTP commands in sequence asynchronously. This is the way the Open() and Mail() commands are implemented.

[Return to Top]
 
Mail:  procedure Mail;

 The combination of the MailFrom(), RcptTo() and Data() methods sent asynchronously in sequence. This is an example implementation of the HighLevelAsync() method.

[Return to Top]
 
MailFrom:  procedure MailFrom;

 Submits the e-mail address of the sender required by the SMTP server to create the envelope. The sender's address is read from the FromName property.

[Return to Top]
 
Open:  procedure Open;

 The combination of the Connect() and Helo() methods sent asynchronously in sequence. If the AuthType property is different than smtpAuthNone then it combines the Connect(), Ehlo() and Auth() methods instead. This is an example implementation of the HighLevelAsync() method.

[Return to Top]
 
Quit:  procedure Quit;

 Closes the SMTP session and disconnects from the server.

[Return to Top]
 
RcptTo:  procedure RcptTo;

 Submits the list of actual recipients to the SMTP server.

[Return to Top]
 
Rset:  procedure Rset;

 Resets the SMTP session. Any sender or recipient previously specified will be cleared.

[Return to Top]
 
SetContentType:  procedure SetContentType(newValue: TSmtpContentType);

 Sets internally the MIME-type of the message body. This method is called automatically when the component is created, but you need to call it manually if you change the ContentType property after that.

[Return to Top]
 
Vrfy:  procedure Vrfy;

 Attempts to verify if an e-mail address is valid for delivery by the SMTP server.

 Note: For security reasons, most SMTP servers disable this command.

[Return to Top]
 

[Globals]

Below is a list of all Globals for use as a quick reference:

[Back to Main]



Below is a list of all Globals with their complete descriptions:

Rfc822DateTime:  function Rfc822DateTime(t: TDateTime): String;

 Converts a TDateTime to an timestamp string as specified in RFC-822. The format of the timestamp is: 'DDD, D MMM YYYY HH:MM:SS TZ'.

[Return to Top]
 

[Notes]

Below is a list of all Notes for use as a quick reference:

[Back to Main]



Below is a list of all Notes with their complete descriptions:

Asynchronous:  TSmtpCli is an asynchronous component. It is non-blocking and event-driven. This means that when you request an operation such as connect, the component starts the operation your requested and gives control back immediately while performing the operation in the background automatically.
[Return to Top]
 



The ICS FAQ is created and maintained by the ICS VIP Documentation Effort Group.
For more information on how to join our efforts, send email to:
[ICS FAQ]



This page was created by Help-FAQ Builder