PHPMailer\PHPMailer\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
Synopsis
class SMTP
{
- // constants
- const VERSION = '6.0.3';
- const LE = "\r\n";
- const DEFAULT_PORT = 25;
- const MAX_LINE_LENGTH = 998;
- const DEBUG_OFF = 0;
- const DEBUG_CLIENT = 1;
- const DEBUG_SERVER = 2;
- const DEBUG_CONNECTION = 3;
- const DEBUG_LOWLEVEL = 4;
- // members
- public int $do_debug = self::DEBUG_OFF;
- public LoggerInterface $Debugoutput = 'echo';
- public bool $do_verp = false;
- public integer $Timeout = 300;
- public integer $Timelimit = 300;
- protected array $smtp_transaction_id_patterns = ;
- protected string|bool|null $last_smtp_transaction_id;
- protected ?resource $smtp_conn;
- protected array $error = ;
- protected string|null $helo_rply = NULL;
- protected array|null $server_caps = NULL;
- protected string $last_reply = '';
- // methods
- protected void edebug()
- public bool connect()
- public bool startTLS()
- public bool authenticate()
- protected string hmac()
- public bool connected()
- public void close()
- public bool data()
- public bool hello()
- protected bool sendHello()
- protected void parseHelloFields()
- public bool mail()
- public bool quit()
- public bool recipient()
- public bool reset()
- protected bool sendCommand()
- public bool sendAndMail()
- public bool verify()
- public bool noop()
- public bool turn()
- public int|bool client_send()
- public array getError()
- public array|null getServerExtList()
- public mixed getServerExt()
- public string getLastReply()
- protected string get_lines()
- public void setVerp()
- public bool getVerp()
- protected void setError()
- public void setDebugOutput()
- public string getDebugOutput()
- public void setDebugLevel()
- public int getDebugLevel()
- public void setTimeout()
- public int getTimeout()
- protected void errorHandler()
- protected bool|null|string recordLastTransactionID()
- public bool|null|string getLastTransactionID()
Constants
Name | Value |
---|---|
VERSION | '6.0.3' |
LE | "\r\n" |
DEFAULT_PORT | 25 |
MAX_LINE_LENGTH | 998 |
DEBUG_OFF | 0 |
DEBUG_CLIENT | 1 |
DEBUG_SERVER | 2 |
DEBUG_CONNECTION | 3 |
DEBUG_LOWLEVEL | 4 |
Members
protected
- $error
—
array
Error information, if any, for the last SMTP command. - $helo_rply
—
PHPMailer\PHPMailer\string|null
The reply the server sent to us for HELO. - $last_reply
—
string
The most recent reply received from the server. - $last_smtp_transaction_id
—
PHPMailer\PHPMailer\string|bool|null
The last transaction ID issued in response to a DATA command, if one was detected. - $server_caps
—
PHPMailer\PHPMailer\array|null
The set of SMTP extensions sent in reply to EHLO command. - $smtp_conn
—
PHPMailer\PHPMailer\?resource
The socket for the server connection. - $smtp_transaction_id_patterns
—
array
Patterns to extract an SMTP transaction id from reply to a DATA command.
public
- $Debugoutput
—
PHPMailer\PHPMailer\string|callable|\Psr\Log\LoggerInterface
How to handle debug output. - $Timelimit
—
int
How long to wait for commands to complete, in seconds. - $Timeout
—
int
The timeout value for connection, in seconds. - $do_debug
—
int
Debug output level. - $do_verp
—
PHPMailer\PHPMailer\bool
Whether to use VERP.
Methods
protected
- edebug() — Output debugging info via a user-selected method.
- errorHandler() — Reports an error number and string.
- get_lines() — Read the SMTP server's response.
- hmac() — Calculate an MD5 HMAC hash.
- parseHelloFields() — Parse a reply to HELO/EHLO command to discover server extensions.
- recordLastTransactionID() — Extract and return the ID of the last SMTP transaction based on a list of patterns provided in SMTP::$smtp_transaction_id_patterns.
- sendCommand() — Send a command to an SMTP server and check its return code.
- sendHello() — Send an SMTP HELO or EHLO command.
- setError() — Set error messages and codes.
public
- authenticate() — Perform SMTP authentication.
- client_send() — Send raw data to the server.
- close() — Close the socket and clean up the state of the class.
- connect() — Connect to an SMTP server.
- connected() — Check connection state.
- data() — Send an SMTP DATA command.
- getDebugLevel() — Get debug output level.
- getDebugOutput() — Get debug output method.
- getError() — Get the latest error.
- getLastReply() — Get the last reply from the server.
- getLastTransactionID() — Get the queue/transaction ID of the last SMTP transaction If no reply has been received yet, it will return null.
- getServerExt() — Get metadata about the SMTP server from its HELO/EHLO response.
- getServerExtList() — Get SMTP extensions available on the server.
- getTimeout() — Get SMTP timeout.
- getVerp() — Get VERP address generation mode.
- hello() — Send an SMTP HELO or EHLO command.
- mail() — Send an SMTP MAIL command.
- noop() — Send an SMTP NOOP command.
- quit() — Send an SMTP QUIT command.
- recipient() — Send an SMTP RCPT command.
- reset() — Send an SMTP RSET command.
- sendAndMail() — Send an SMTP SAML command.
- setDebugLevel() — Set debug output level.
- setDebugOutput() — Set debug output method.
- setTimeout() — Set SMTP timeout.
- setVerp() — Enable or disable VERP address generation.
- startTLS() — Initiate a TLS (encrypted) session.
- turn() — Send an SMTP TURN command.
- verify() — Send an SMTP VRFY command.