Path

ez components / documentation / api reference / 1.1 / mail


eZ Components 1.1

Mail: ezcMailSmtpTransport

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcMailSmtpTransport

This class implements the Simple Mail Transfer Protocol (SMTP) with authentication support. [source]

Implemented Interfaces

The ezcMailTransportSmtp class has the following properties:
  • string serverHost, the SMTP server host to connect to.
  • int serverPort, the port of the SMTP server. Defaults to 25.
  • string username, the username used for authentication. The default is blank which means no authentication.
  • string password, the password used for authentication.
  • int timeout, the timeout value of the connection in seconds. The default is five seconds.
  • string senderHost, the hostname of the computer that sends the mail. the default is 'localhost'.
See for further information the RFC's:

Descendents

Child Class Description
ezcMailTransportSmtp This class is deprecated. Use ezcMailSmtpTransport instead.

Constants

CRLF = "\r\n" The line-break characters to use.

Method Summary

protected void cmdRcpt( $email, $to )
Sends the 'RCTP TO' to the server with the address $email.
public void __construct( $host, [$user = ''], [$password = ''], [$port = 25] )
Constructs a new ezcMailTransportSmtp.
public void __destruct( )
Destructs this object.
public void disconnect( )
Sends the QUIT command to the server and breaks the connection.
public void keepConnection( )
Sets if the connection should be kept open after sending an email.
public void send( $mail )
Sends the ezcMail $mail using the SMTP protocol.
public mixed __get( $name )
Returns the property $name.
public void __set( $name, $value )
Sets the property $name to $value.

Methods

cmdRcpt

void cmdRcpt( $email, string $to )
Sends the 'RCTP TO' to the server with the address $email.
This method must be called once for each recipient of the mail including cc and bcc recipients. The RCPT TO commands control where the mail is actually sent. It does not affect the headers of the email.
The recipient mail address $email may be enclosed in angle brackets.

Parameters

Name Type Description
$to string  
$email  

Throws

ClassDescription
ezcMailTransportException if there is no valid connection or if the RCPT TO command failed.

__construct

void __construct( string $host, [string $user = ''], [string $password = ''], [int $port = 25] )
Constructs a new ezcMailTransportSmtp.
The constructor expects, at least, the hostname $host of the SMTP server.
The username $user will be used for authentication if provided. If it is left blank no authentication will be performed.
The password $password will be used for authentication if provided. Use this parameter always in combination with the $user parameter.
The portnumber $port, default the SMTP standard port, to which will be connected.

Parameters

Name Type Description
$host string  
$user string  
$password string  
$port int  

__destruct

void __destruct( )
Destructs this object.
Closes the connection if it is still open.

disconnect

void disconnect( )
Sends the QUIT command to the server and breaks the connection.

Throws

ClassDescription
ezcMailTransportException if the QUIT command failed.

keepConnection

void keepConnection( )
Sets if the connection should be kept open after sending an email.
This method should be called prior to the first call to send().
Keeping the connection open is useful if you are sending a lot of mail. It removes the overhead of opening the connection after each mail is sent.
Use disconnect() to close the connection if you have requested to keep it open.

send

void send( ezcMail $mail )
Sends the ezcMail $mail using the SMTP protocol.
If you want to send several email use keepConnection() to leave the connection to the server open between each mail.

Parameters

Name Type Description
$mail ezcMail  

Throws

ClassDescription
ezcMailTransportException if the mail could not be sent.

__get

mixed __get( string $name )
Returns the property $name.

Parameters

Name Type Description
$name string  

Throws

ClassDescription
ezcBasePropertyNotFoundException if the property does not exist.

__set

void __set( string $name, mixed $value )
Sets the property $name to $value.

Parameters

Name Type Description
$name string  
$value mixed  

Throws

ClassDescription
ezcBasePropertyNotFoundException if the property does not exist.

Last updated: Wed, 28 Nov 2007