Mail: ezcMailSmtpTransport
[ ]
[ Display example ] [ Mail listing example ] [ Rfcs ]
[ ]
[ ]
[ ]
[ ]
Class: ezcMailSmtpTransport
|
This class implements the Simple Mail Transfer Protocol (SMTP) with authentication support. [
source]
Implemented Interfaces
See for further information the RFCs:
Constants
Properties
|
ezcMailSmtpTransportOptions |
read/write
|
$options
Holds the options you can set to the SMTP transport. |
|
string |
read/write
|
$password
The password used for authentication. |
|
string |
read/write
|
$senderHost
The hostname of the computer that sends the mail. The default is 'localhost'. |
|
string |
read/write
|
$serverHost
The SMTP server host to connect to. |
|
int |
read/write
|
$serverPort
The port of the SMTP server. Defaults to 25. |
|
int |
read/write
|
$timeout
The timeout value of the connection in seconds. The default is 5 seconds. When setting/getting this option, the timeout option from $this->options will be set instead ezcMailTransportOptions. |
|
string |
read/write
|
$username
The username used for authentication. The default is blank which means no authentication. |
Method Summary
|
public ezcMailSmtpTransport |
__construct(
$host, [$user = ''], [$password = ''], [$port = null], [$options = array()] )
Constructs a new ezcMailSmtpTransport. |
|
public void |
__destruct(
)
Destructs this object. |
|
protected void |
cmdRcpt(
$email )
Sends the 'RCTP TO' to the server with the address $email. |
|
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. |
Methods
__construct
ezcMailSmtpTransport __construct(
string
$host, [string
$user = ''], [string
$password = ''], [int
$port = null], [
$options = array()] )
Constructs a new ezcMailSmtpTransport.
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 value $port specifies on which port to connect to $host. By default it is 25 for plain connections and 465 for TLS/SSL/SSLv2/SSLv3.
Note: The ssl option from ezcMailTransportOptions doesn't apply to SMTP. If you want to connect to SMTP using TLS/SSL/SSLv2/SSLv3 use the connectionType option in ezcMailSmtpTransportOptions.
Parameters
| Name |
Type |
Description |
$host |
string |
|
$user |
string |
|
$password |
string |
|
$port |
int |
|
$options |
array(string=>mixed) |
|
Throws
| Class | Description |
ezcBasePropertyNotFoundException |
if $options contains a property not defined |
ezcBaseValueException |
if $options contains a property with a value not allowed |
__destruct
void __destruct(
)
Destructs this object.
Closes the connection if it is still open.
cmdRcpt
void cmdRcpt(
string
$email )
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 |
$email |
string |
|
Throws
| Class | Description |
ezcMailTransportSmtpException |
if there is no valid connection or if the RCPT TO command failed |
disconnect
void disconnect(
)
Sends the QUIT command to the server and breaks the connection.
Throws
| Class | Description |
ezcMailTransportSmtpException |
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
Sends the ezcMail $mail using the SMTP protocol.
If you want to send several emails use keepConnection() to leave the connection to the server open between each mail.
Parameters
| Name |
Type |
Description |
$mail |
ezcMail |
|
Throws
| Class | Description |
ezcMailTransportException |
if the mail could not be sent |
ezcBaseFeatureNotFoundException |
if trying to use SSL and the openssl extension is not installed |
Last updated: Wed, 28 Nov 2007