Class SMTP
PHPMailer RFC821 SMTP email transport class. Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
Author: Chris Ryan
Author: Marcus Bointon phpmailer@synchromedia.co.uk
Used by: PHPMailer\PHPMailer\PHPMailer::smtpSend()
Used by: PHPMailer\PHPMailer\PHPMailer::smtpConnect()
Located at zp-extensions/PHPMailer/SMTP.php
protected
|
|
public
boolean
|
|
protected
false|resource
|
#
getSMTPConnection( string $host, integer $port = null, integer $timeout = 30, array $options = [] )
Create connection to the SMTP server. |
public
boolean
|
|
public
boolean
|
#
authenticate( string $username, string $password, string $authtype = null, OAuth $OAuth = null )
Perform SMTP authentication. Must be run after hello(). |
protected
string
|
|
public
boolean
|
|
public
|
|
public
boolean
|
#
data( string $msg_data )
Send an SMTP DATA command.
Issues a data command and sends the msg_data to the server,
finializing the mail transaction. $msg_data is the message
that is to be send with the headers. Each header needs to be
on a single line followed by a |
public
boolean
|
|
protected
boolean
|
|
protected
|
#
parseHelloFields( string $type )
Parse a reply to HELO/EHLO command to discover server extensions. In case of HELO, the only parameter that can be discovered is a server name. |
public
boolean
|
#
mail( string $from )
Send an SMTP MAIL command.
Starts a mail transaction from the email address specified in
$from. Returns true if successful or false otherwise. If True
the mail transaction is started and then one or more recipient
commands may be called followed by a data command.
Implements RFC 821: MAIL |
public
boolean
|
|
public
boolean
|
|
public
boolean
|
|
protected
boolean
|
#
sendCommand( string $command, string $commandstring, integer|array $expect )
Send a command to an SMTP server and check its return code. |
public
boolean
|
#
sendAndMail( string $from )
Send an SMTP SAML command.
Starts a mail transaction from the email address specified in $from.
Returns true if successful or false otherwise. If True
the mail transaction is started and then one or more recipient
commands may be called followed by a data command. This command
will send the message to the users terminal if they are logged
in and send them an email.
Implements RFC 821: SAML |
public
boolean
|
|
public
boolean
|
|
public
boolean
|
|
public
integer|boolean
|
|
public
array
|
|
public
array|null
|
|
public
string|boolean|null
|
#
getServerExt( string $name )
Get metadata about the SMTP server from its HELO/EHLO response. The method works in three ways, dependent on argument value and current state: 1. HELO/EHLO has not been sent - returns null and populates $this->error. 2. HELO has been sent - $name == 'HELO': returns server name $name == 'EHLO': returns boolean false $name == any other string: returns null and populates $this->error 3. EHLO has been sent - $name == 'HELO'|'EHLO': returns the server name $name == any other string: if extension $name exists, returns True or its options (e.g. AUTH mechanisms supported). Otherwise returns False. |
public
string
|
|
protected
string
|
|
public
|
|
public
boolean
|
|
protected
|
|
public
|
|
public
string
|
|
public
|
|
public
integer
|
|
public
|
|
public
integer
|
|
protected
|
#
errorHandler( integer $errno, string $errmsg, string $errfile = '', integer $errline = 0 )
Reports an error number and string. |
protected
boolean|string|null
|
#
recordLastTransactionID( )
Extract and return the ID of the last SMTP transaction based on a list of patterns provided in SMTP::$smtp_transaction_id_patterns. Relies on the host providing the ID in response to a DATA command. If no reply has been received yet, it will return null. If no pattern was matched, it will return false. |
public
boolean|string|null
|
#
getLastTransactionID( )
Get the queue/transaction ID of the last SMTP transaction If no reply has been received yet, it will return null. If no pattern was matched, it will return false. |
string |
VERSION
The PHPMailer SMTP version number. |
#
'6.4.1'
|
string |
LE
SMTP line break constant. |
#
"\r\n"
|
integer |
DEFAULT_PORT
The SMTP port to use if one is not specified. |
#
25
|
integer |
MAX_LINE_LENGTH
The maximum line length allowed by RFC 5321 section 4.5.3.1.6, excluding a trailing CRLF break. |
#
998
|
integer |
MAX_REPLY_LENGTH
The maximum line length allowed for replies in RFC 5321 section 4.5.3.1.5, including a trailing CRLF line break. |
#
512
|
integer |
DEBUG_OFF
Debug level for no output. |
#
0
|
integer |
DEBUG_CLIENT
Debug level to show client -> server messages. |
#
1
|
integer |
DEBUG_SERVER
Debug level to show client -> server and server -> client messages. |
#
2
|
integer |
DEBUG_CONNECTION
Debug level to show connection status, client -> server and server -> client messages. |
#
3
|
integer |
DEBUG_LOWLEVEL
Debug level to show all messages. |
#
4
|
public
integer
|
$do_debug
Debug output level.
Options:
* self::DEBUG_OFF ( |
#
self::DEBUG_OFF
|
public
string|callable|Psr\Log\LoggerInterface
|
$Debugoutput
How to handle debug output.
Options:
* |
#
'echo'
|
public
boolean
|
$do_verp
Whether to use VERP. |
#
false
|
public
integer
|
$Timeout
The timeout value for connection, in seconds. Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2. This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. |
#
300
|
public
integer
|
$Timelimit
How long to wait for commands to complete, in seconds. Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2. |
#
300
|
protected
string[]
|
$smtp_transaction_id_patterns
Patterns to extract an SMTP transaction id from reply to a DATA command. The first capture group in each regex will be used as the ID. MS ESMTP returns the message ID, which may not be correct for internal tracking. |
#
[
'exim' => '/[\d]{3} OK id=(.*)/',
'sendmail' => '/[\d]{3} 2.0.0 (.*) Message/',
'postfix' => '/[\d]{3} 2.0.0 Ok: queued as (.*)/',
'Microsoft_ESMTP' => '/[0-9]{3} 2.[\d].0 (.*)@(?:.*) Queued mail for delivery/',
'Amazon_SES' => '/[\d]{3} Ok (.*)/',
'SendGrid' => '/[\d]{3} Ok: queued as (.*)/',
'CampaignMonitor' => '/[\d]{3} 2.0.0 OK:([a-zA-Z\d]{48})/',
]
|
protected
string|boolean|null
|
$last_smtp_transaction_id
The last transaction ID issued in response to a DATA command, if one was detected. |
|
protected
?resource
|
$smtp_conn
The socket for the server connection. |
|
protected
array
|
$error
Error information, if any, for the last SMTP command. |
#
[
'error' => '',
'detail' => '',
'smtp_code' => '',
'smtp_code_ex' => '',
]
|
protected
string|null
|
$helo_rply
The reply the server sent to us for HELO. If null, no HELO string has yet been received. |
|
protected
array|null
|
$server_caps
The set of SMTP extensions sent in reply to EHLO command. Indexes of the array are extension names. Value at index 'HELO' or 'EHLO' (according to command that was sent) represents the server name. In case of HELO it is the only element of the array. Other values can be boolean TRUE or an array containing extension options. If null, no HELO/EHLO string has yet been received. |
|
protected
string
|
$last_reply
The most recent reply received from the server. |
#
''
|