Indy 9
TIdSMTP
Hierarchy, Properties, Methods, Events, See Also, Unit: IdSMTP
Implements a Simple Mail Transfer Protocol client.
TIdSMTP = class(TIdMessageClient)
Unit
IdSMTP
Description
TIdSMTP is a TIdMessageClient descendant that implements a Simple Mail Transfer Protocol or SMTP client, as described in the Internet Standards documents:

  • RFC 821 - Simple Mail Transfer Protocol [SMTP] (http://www.rfc-editor.org/rfc/rfc821.txt)

  • RFC 1869 - SMTP Service Extensions (http://www.rfc-editor.org/rfc/rfc1869.txt)

  • RFC 2554 - SMTP Service Extension for Authentication (http://www.rfc-editor.org/rfc/rfc2554.txt)

Use TIdPOP3 or TIdIMAP4 to retrieve E-Mail messages from a mail server to the user's computer.


TIdSMTP.AuthenticationType
TIdSMTP
Authentication type required to connect to the SMTP host.
property AuthenticationType: TAuthenticationType;
Description
AuthenticationType is a TAuthenticationType property that specifies the authentication type to use when accessing the E-Mail server. AuthenticationType can contain one of the following values:

  • atNone - no authentication is required.

  • atLogin - simple username and password authentication is required (AUTH LOGIN).

You can find the authentication mechanisms supported on the E-Mail server identified in Host by using AuthSchemesSupported.


TIdSMTP.AuthSchemesSupported
TIdSMTP
List of supported authentication methods for the SMTP server.
property AuthSchemesSupported: TStringList;
Description
AuthSchemesSupported is a read-only TStringList property that contains the authentication methods supported by an SMTP Mail server. AuthSchemesSupported is valid only when you are connected to the server. Set AuthenticationType to the appropriate value for one of the authentication schemes supported on the SMTP server.

Note: Any given SMTP server can support authentication mechanisms which may not be implemented in TIdSMTP.


TIdSMTP.HeloName
TIdSMTP, See Also
Identities the client connecting to an SMTP server.
property HeloName: string;
Description
HeloName is a String property that represents the identity name of the client establishing a connection to the SMTP server using either the SMTP EHLO or HELO command verbs. HeloName is used in Connect to hail the SMTP server. when HeloName contains a blank value, LocalName is used when hailing the SMTP server.

TIdSMTP.MailAgent
TIdSMTP, See Also
Identifies the program that created a message.
property MailAgent: string;
Description
MailAgent is a String property that identifies the name of a program used to create or transmit a message. MailAgent specifies your program name, and is placed in the SMTP 'X-Mailer' header in the Send method.

TIdSMTP.Password
TIdSMTP, See Also
Specifies the password used for SMTP account authentication.
property Password;
Description
Password is a String property that specifies the password used for SMTP account authentication. Username and Password are used by Authenticate when AuthenticationType is atLogin.

TIdSMTP.UseEhlo
TIdSMTP, See Also
Indicates the SMTP client desires authetication type information from the SMTP server.
property UseEhlo: Boolean;
Description
UseEhlo is a Boolean property that indicates the SMTP client desires authetication type information from the SMTP server. When UseEhlo is True, the client will connect with the SMTP EHLO greeting that instructs the server to send supported authentication types after the banner greeting.

UseEhlo is used in the Connect method prior to sending the value from HeloName (or LocalName) to the SMTP server. When UseEhlo is True, the client identification is sent using the SMTP EHLO command. Authentication types supported by the server are captured upon successful completion of the EHLO command. When UseEhlo is False, the SMTP HELO command is used for client identification.

Note: Changing the value of UseEhlo from True to False forces the AuthenticationType property to be reset to the value atNone. An application must set the correct value for AuthenticationType after changing UseEhlo from True to False.


TIdSMTP.Username
TIdSMTP, See Also
Specifies the user account for the SMTP server.
property Username;
Description
Username is a String property that specifies the user name used to log on to the SMTP Server. Username and Password are used, in Authenticate, to perform account verification when AuthenticationType is atLogin.

TIdSMTP.Assign
TIdSMTP
Copies property values to the current object instance.
procedure Assign(Source: TPersistent); override;
Parameters
Source: TPersistent
Object instance containing property values to be copied.
Description
Assign is a procedure that allows an persistent object instance to copy property values from another persistent object instance to the current instance.

Assign will load the following property values:


TIdSMTP.Authenticate
TIdSMTP
Performs account authentication on the SMTP server.
function Authenticate: Boolean; virtual;
Return Value
Boolean - True on success.
Description
Authenticate is a Boolean function that performs account authentication on the SMTP server. Authenticate returns True when successful, or False if authentication failed.

You must specify the AuthenticationType before calling the Authenticate method. Authenticate should be called only once for a SMTP session.

Send will also call Authenticate before transmission of an E-Mail message, if the SMTP session has not been authenticated.

When AuthenticationType is atLogin, Authenticate sends the SMTP AUTH LOGIN command followed by the Base64-encoded values for Username and Password to the server.


TIdSMTP.Connect
TIdSMTP
Opens a connection to the SMTP server.
procedure Connect(const ATimeout: Integer = IdTimeoutDefault); override;
Parameters
const ATimeout: Integer = IdTimeoutDefault
Connection timeout in milliseconds. Default value is IdTimeoutDefault.
Description
Connect is a procedure that opens a connection to the SMTP server using the Host and Port properties. An exception will be raised if the connection fails or returns an invalid SMTP response code.

After establishing the socket connection, Connect will clear AuthSchemesSupported. Connect hails the server using either the HeloName or the LocalName properties using either the SMTP EHLO or HELO commands. When the EHLO command is supported on the SMTP server, AuthSchemesSupported will be loaded.

If an exception is raised in Connect, the SMTP client will call Disconnect and the exception will be re-raised.


TIdSMTP.Create
TIdSMTP, See Also
Constructor for the object instance.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the constructor for the object instance. Create initializes AuthSchemesSupported to ignore duplicate entries, and sets Port to the default SMTP port number (IdPORT_SMTP).

TIdSMTP.Destroy
TIdSMTP, See Also
Frees the object instance.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance. Destroy clears and releases the AuthSchemesSupported property prior to calling the inherited Destroy method.

TIdSMTP.Disconnect
TIdSMTP
Closes the SMTP session.
procedure Disconnect; override;
Description
Disconnect is a procedure that closes the SMTP session. When Connected is True, the SMTP QUIT command is used to inform the server that the session will be ended. Disconnect calls the inherited Disconnect method, and indicates that the SMTP session has not been previously authenticated.

TIdSMTP.Expand
TIdSMTP, See Also
Determines group membership for a mailing list or mailbox alias.
procedure Expand(AUserName: String; AResults: TStrings); virtual;
Parameters
AUserName: String
Mail list or alias to be expanded.
AResults: TStrings
Membership in the list or alias.
Description
Expand is a procedure used to determine if the argument in AUsername is a valid mailing list or mailbox alias on the server, and retrieve the email addresses for the membership of that list in AResults. Expand uses the SMTP EXPN command to retrieve the results, with one name and email address per line.

The following is an example of successful result values that might be returned in AResults when using Expand with the Username 'Example-People':

    Jon Postel 
    Fred Fonebone 
    Sam Q. Smith 
    Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA>
    
    

Use Verify to validate an individual name or address on the SMTP server.


TIdSMTP.QuickSend
TIdSMTP
Sends a message without an Indy message instance.
class procedure QuickSend(const AHost: String; const ASubject: String; const ATo: String; const AFrom: String; const AText: String);
Parameters
const AHost: String
SMTP server used to send the message.
const ASubject: String
Subject of the message.
const ATo: String
Recipient(s) of the message.
const AFrom: String
Person sending the message.
const AText: String
Body text for the message.
Description
QuickSend is a class procedure that allows the SMTP client to quickly send a message without the need for a TIdMessage instance. QuickSend cannot be used to send messages with attachments. Use Send to transfer messages that include attachments.

Parameters for the method are used to construct a TIdMessage instance, connect and send the message to the SMTP server, and to Disconnect from the SMTP server. The following is an example of using QuickSend with pre-defined application variables:

  try
    ASmtp.QuickSend(SMailhost, SSubject, SUserAccount,
      SContactAccount, ABody.Text);
  except on E:
    do DoReminderTransmitError(E);
  end;

TIdSMTP.Send
TIdSMTP
Sends an Indy message instance to the SMTP server.
procedure Send(AMsg: TIdMessage); virtual;
Parameters
AMsg: TIdMessage
Message instance to be transmitted.
Description
Send is a procedure that sends the TIdMessage specified in AMsg using the SMTP server specified in the Host property. Send will reset the SMTP session, and call Authenticate when the SMTP session has never been authenticated.

Send transmits RFC 822 message headers to the SMTP server, including From, Recipients, Carbon-Copy recipients, and Blind Carbon-Copy recipients before sending the data and extra RFC 822 message headers for the message. Send inserts the value in MailAgent header as the first values in the data for the message. Send terminates transfer of data to the SMTP server using the '.' end-of-transmission marker.


TIdSMTP.Verify
TIdSMTP, See Also
Verifies that an alias or name is a user mailbox on the SMTP server.
function Verify(AUserName: String): String; virtual;
Parameters
AUserName: String
Value to be verified.
Return Value
String - Fully qualified User name and email address.
Description
Verify is a String function used to verify that the User specified in AUsername is a valid address on the SMTP server. Verify returns the fully sepecified User name and email address on success. Use Expand to determine the membership in a mailing list.

The following is an example of the value returned from a successful Verify command request using 'Smith' in AUsername:

    Fred Smith 

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.