VERSION
VERSION
The PHPMailer SMTP version number.
PHPMailer RFC821 SMTP email transport class.
Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
$do_debug : integer
Debug output level.
Options:
0
) No debug output, default1
) Client commands2
) Client commands and server responses3
) As DEBUG_SERVER plus connection status4
) Low-level data output, all messages.$Debugoutput : string|callable|\Psr\Log\LoggerInterface
How to handle debug output.
Options:
echo
Output plain-text as-is, appropriate for CLIhtml
Output escaped, line breaks converted to <br>
, appropriate for browser outputerror_log
Output to error log as configured in php.ini
Alternatively, you can provide a callable expecting two params: a message string and the debug level:$smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only debug
level output is used:
$mail->Debugoutput = new myPsr3Logger;
$smtp_transaction_id_patterns : array<mixed,string>
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.
$server_caps : array|null
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.
connect(string $host, integer $port = null, integer $timeout = 30, array $options = array()) : boolean
Connect to an SMTP server.
string | $host | SMTP server IP or host name |
integer | $port | The port number to connect to |
integer | $timeout | How long to wait for the connection to open |
array | $options | An array of options for stream_context_create() |
authenticate(string $username, string $password, string $authtype = null, \PHPMailer\PHPMailer\OAuth $OAuth = null) : boolean
Perform SMTP authentication.
Must be run after hello().
string | $username | The user name |
string | $password | The password |
string | $authtype | The auth type (CRAM-MD5, PLAIN, LOGIN, XOAUTH2) |
\PHPMailer\PHPMailer\OAuth | $OAuth | An optional OAuth instance for XOAUTH2 authentication |
True if successfully authenticated
data(string $msg_data) : boolean
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
string | $msg_data | Message data to send |
hello(string $host = '') : boolean
Send an SMTP HELO or EHLO command.
Used to identify the sending server to the receiving server.
This makes sure that client and server are in a known state.
Implements RFC 821: HELO
string | $host | The host name or IP to connect to |
mail(string $from) : boolean
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
string | $from | Source address of this message |
sendAndMail(string $from) : boolean
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
string | $from | The address the message is from |
client_send(string $data, string $command = '') : integer|boolean
Send raw data to the server.
string | $data | The data to send |
string | $command | Optionally, the command this is part of, used only for controlling debug output |
The number of bytes sent to the server or false on error
getServerExt(string $name) : mixed
Get metadata about the SMTP server from its HELO/EHLO response.
The method works in three ways, dependent on argument value and current state:
string | $name | Name of SMTP extension or 'HELO'|'EHLO' |
sendCommand(string $command, string $commandstring, integer|array $expect) : boolean
Send a command to an SMTP server and check its return code.
string | $command | The command name - not sent to the server |
string | $commandstring | The actual command to send |
integer|array | $expect | One or more expected integer success codes |
True on success
setError(string $message, string $detail = '', string $smtp_code = '', string $smtp_code_ex = '')
Set error messages and codes.
string | $message | The error message |
string | $detail | Further detail on the error |
string | $smtp_code | An associated SMTP error code |
string | $smtp_code_ex | Extended SMTP code |
errorHandler(integer $errno, string $errmsg, string $errfile = '', integer $errline)
Reports an error number and string.
integer | $errno | The error number returned by PHP |
string | $errmsg | The error message returned by PHP |
string | $errfile | The file the error occurred in |
integer | $errline | The line number the error occurred on |
recordLastTransactionID() : boolean|null|string
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.