PHPMailer RFC821 SMTP email transport class.
Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
| package | PHPMailer |
|---|---|
| author | Chris Ryan |
| author | Marcus Bointon |
authenticate(string $username, string $password, string $authtype= null, string $realm= '', string $workstation= '', null|\OAuth $OAuth= null) : boolean
Must be run after hello().
| see |
|---|
stringThe user name
stringThe password
stringThe auth type (PLAIN, LOGIN, CRAM-MD5)
stringThe auth realm for NTLM
stringThe auth workstation for NTLM
null\OAuthAn optional OAuth instance (@see PHPMailerOAuth)
booleanTrue if successfully authenticated.* @access publicclient_send(string $data) : integer | boolean
| access | public |
|---|
stringThe data to send
integerbooleanThe number of bytes sent to the server or false on errorclose() : void
connect(string $host, integer $port= null, integer $timeout= 30, array $options= array()) : boolean
| access | public |
|---|
stringSMTP server IP or host name
integerThe port number to connect to
integerHow long to wait for the connection to open
arrayAn array of options for stream_context_create()
booleanconnected() : boolean
| access | public |
|---|
booleanTrue if connected.data(string $msg_data) : boolean
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
| access | public |
|---|
stringMessage data to send
booleangetDebugLevel() : integer
integergetDebugOutput() : string
stringgetError() : array
| access | public |
|---|
arraygetLastReply() : string
| access | public |
|---|
stringgetLastTransactionID() : boolean | null | string
getServerExt(string $name) : mixed
stringName of SMTP extension or 'HELO'|'EHLO'
mixedgetServerExtList() : array | null
| access | public |
|---|
arraynull
getTimeout() : integer
integergetVerp() : boolean
booleanhello(string $host = '') : boolean
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
| access | public |
|---|
stringThe host name or IP to connect to
booleanmail(string $from) : boolean
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
| access | public |
|---|
stringSource address of this message
booleannoop() : boolean
Used to keep keep-alives alive, doesn't actually do anything
| access | public |
|---|
booleanquit(boolean $close_on_error = true) : boolean
Closes the socket if there is no error or the $close_on_error argument is true.
Implements from rfc 821: QUIT
| access | public |
|---|
booleanShould the connection close if an error occurs?
booleanrecipient(string $address) : boolean
Sets the TO argument to $toaddr.
Returns true if the recipient was accepted false if it was rejected.
Implements from rfc 821: RCPT
| access | public |
|---|
stringThe address the message is being sent to
booleanreset() : boolean
Abort any transaction that is currently in progress.
Implements rfc 821: RSET
| access | public |
|---|
booleanTrue on success.sendAndMail(string $from) : boolean
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
| access | public |
|---|
stringThe address the message is from
booleansetDebugLevel(integer $level = 0)
integer
setDebugOutput(string|callable $method = 'echo')
stringcallableThe name of the mechanism to use for debugging output, or a callable to handle it.
setTimeout(integer $timeout = 0)
integer
setVerp(boolean $enabled = false)
boolean
startTLS() : boolean
| access | public |
|---|
booleanturn() : boolean
This is an optional command for SMTP that this class does not support.
This method is here to make the RFC821 Definition complete for this class
and may be implemented in future
Implements from rfc 821: TURN
| access | public |
|---|
booleanverify(string $name) : boolean
| access | public |
|---|
stringThe name to verify
booleanedebug(string $str, integer $level = 0) : void
errorHandler(integer $errno, string $errmsg, string $errfile= '', integer $errline= 0)
integerThe error number returned by PHP.
stringThe error message returned by PHP.
stringThe file the error occurred in
integerThe line number the error occurred on
get_lines() : string
Either before eof or socket timeout occurs on the operation. With SMTP we can tell if we have more lines to read if the 4th character is '-' symbol. If it is a space then we don't need to read anything else.
| access | protected |
|---|
stringhmac(string $data, string $key) : string
Works like hash_hmac('md5', $data, $key) in case that function is not available
| access | protected |
|---|
stringThe data to hash
stringThe key to hash with
stringparseHelloFields(string $type)
In case of HELO, the only parameter that can be discovered is a server name.
| access | protected |
|---|
stringrecordLastTransactionID() : boolean | null | string
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.
booleannullstring
sendCommand(string $command, string $commandstring, integer|array $expect) : boolean
| access | protected |
|---|
stringThe command name - not sent to the server
stringThe actual command to send
integerarrayOne or more expected integer success codes
booleanTrue on success.sendHello(string $hello, string $host) : boolean
setError(string $message, string $detail= '', string $smtp_code= '', string $smtp_code_ex= '')
stringThe error message
stringFurther detail on the error
stringAn associated SMTP error code
stringExtended SMTP code
$CRLF : string
"\r\n"$Debugoutput : string | callable
'echo'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.iniAlternatively, 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";};
$SMTP_PORT : integer
25$Timelimit : integer
300Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
$Timeout : integer
300Default 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.
| link | http://tools.ietf.org/html/rfc2821#section-4.5.3.2 |
|---|
$Version : string
'5.2.27'$do_debug : integer
self::DEBUG_OFFOptions:
0) No debug output, default1) Client commands2) Client commands and server responses3) As DEBUG_SERVER plus connection status4) Low-level data output, all messages$do_verp : boolean
false$error : array
array('error' => '', 'detail' => '', 'smtp_code' => '', 'smtp_code_ex' => '')$helo_rply : string | null
nullIf null, no HELO string has yet been received.
$last_reply : string
''$last_smtp_transaction_id : string
$server_caps : array | null
nullIndexes 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.
$smtp_conn : resource
$smtp_transaction_id_patterns : array
array('exim' => '/[0-9]{3} OK id=(.*)/', 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/', 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/')CRLF = "\r\n" : string
DEBUG_CLIENT = 1
DEBUG_CONNECTION = 3
DEBUG_LOWLEVEL = 4
DEBUG_OFF = 0
DEBUG_SERVER = 2
DEFAULT_SMTP_PORT = 25 : integer
MAX_LINE_LENGTH = 998 : integer
VERSION = '5.2.27' : string