protected
|
#
edebug( string $str, integer $level = 0 )
Output debugging info via a user-selected method.
Output debugging info via a user-selected method.
Parameters
- $str
string - $str Debug string to output
- $level
integer - $level The debug level of this message; see DEBUG_* constants
See
|
public
boolean
|
#
connect( string $host, integer $port = null, integer $timeout = 30, array $options = array() )
Connect to an SMTP server.
Connect to an SMTP server.
Parameters
- $host
string - $host SMTP server IP or host name
- $port
integer - $port The port number to connect to
- $timeout
integer - $timeout How long to wait for the connection to open
- $options
array - $options An array of options for stream_context_create()
Returns
boolean
|
public
boolean
|
#
startTLS( )
Initiate a TLS (encrypted) session.
Initiate a TLS (encrypted) session.
Returns
boolean
|
public
boolean
|
#
authenticate( string $username, string $password, string $authtype = null, string $realm = '', string $workstation = '', null|OAuth $OAuth = null )
Perform SMTP authentication. Must be run after hello().
Perform SMTP authentication. Must be run after hello().
Parameters
- $username
string - $username The user name
- $password
string - $password The password
- $authtype
string - $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2)
- $realm
string - $realm The auth realm for NTLM
- $workstation
string - $workstation The auth workstation for NTLM
- $OAuth
null|OAuth - $OAuth An optional OAuth instance (@see PHPMailerOAuth)
Returns
boolean - True if successfully authenticated.* @access public
See
|
protected
string
|
#
hmac( string $data, string $key )
Calculate an MD5 HMAC hash. Works like hash_hmac('md5', $data, $key) in case
that function is not available
Calculate an MD5 HMAC hash. Works like hash_hmac('md5', $data, $key) in case
that function is not available
Parameters
- $data
string - $data The data to hash
- $key
string - $key The key to hash with
Returns
string
|
public
boolean
|
#
connected( )
Check connection state.
Returns
boolean - True if connected.
|
public
|
#
close( )
Close the socket and clean up the state of the class. Don't use this function
without first trying to use QUIT.
Close the socket and clean up the state of the class. Don't use this function
without first trying to use QUIT.
See
|
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 <CRLF> with the message headers and the message body being separated
by and additional <CRLF>. Implements rfc 821: DATA <CRLF>
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 <CRLF> with the message headers and the message body being separated
by and additional <CRLF>. Implements rfc 821: DATA <CRLF>
Parameters
- $msg_data
string - $msg_data Message data to send
Returns
boolean
|
public
boolean
|
#
hello( string $host = '' )
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 <SP> <domain> <CRLF> and RFC 2821
EHLO.
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 <SP> <domain> <CRLF> and RFC 2821
EHLO.
Parameters
- $host
string - $host The host name or IP to connect to
Returns
boolean
|
protected
boolean
|
#
sendHello( string $hello, string $host )
Send an SMTP HELO or EHLO command. Low-level implementation used by
hello()
Send an SMTP HELO or EHLO command. Low-level implementation used by
hello()
Parameters
- $hello
string - $hello The HELO string
- $host
string - $host The hostname to say we are
Returns
boolean
See
|
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.
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.
Parameters
- $type
string - $type - 'HELO' or 'EHLO'
|
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 <SP>
FROM:<reverse-path> <CRLF>
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 <SP>
FROM:<reverse-path> <CRLF>
Parameters
- $from
string - $from Source address of this message
Returns
boolean
|
public
boolean
|
#
quit( boolean $close_on_error = true )
Send an SMTP QUIT command. Closes the socket if there is no error or the
$close_on_error argument is true. Implements from rfc 821: QUIT <CRLF>
Send an SMTP QUIT command. Closes the socket if there is no error or the
$close_on_error argument is true. Implements from rfc 821: QUIT <CRLF>
Parameters
- $close_on_error
boolean - $close_on_error Should the connection close if an error occurs?
Returns
boolean
|
public
boolean
|
#
recipient( string $address )
Send an SMTP RCPT command. Sets the TO argument to $toaddr. Returns true if
the recipient was accepted false if it was rejected. Implements from rfc 821:
RCPT <SP> TO:<forward-path> <CRLF>
Send an SMTP RCPT command. Sets the TO argument to $toaddr. Returns true if
the recipient was accepted false if it was rejected. Implements from rfc 821:
RCPT <SP> TO:<forward-path> <CRLF>
Parameters
- $address
string - $address The address the message is being sent to
Returns
boolean
|
public
boolean
|
#
reset( )
Send an SMTP RSET command. Abort any transaction that is currently in
progress. Implements rfc 821: RSET <CRLF>
Send an SMTP RSET command. Abort any transaction that is currently in
progress. Implements rfc 821: RSET <CRLF>
Returns
boolean - True on success.
|
protected
boolean
|
#
sendCommand( string $command, string $commandstring, integer|array $expect )
Send a command to an SMTP server and check its return code.
Send a command to an SMTP server and check its return code.
Parameters
- $command
string - $command The command name - not sent to the server
- $commandstring
string - $commandstring The actual command to send
- $expect
integer|array - $expect One or more expected integer success codes
Returns
boolean - True on success.
|
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 <SP> FROM:<reverse-path> <CRLF>
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 <SP> FROM:<reverse-path> <CRLF>
Parameters
- $from
string - $from The address the message is from
Returns
boolean
|
public
boolean
|
#
verify( string $name )
Send an SMTP VRFY command.
Send an SMTP VRFY command.
Parameters
- $name
string - $name The name to verify
Returns
boolean
|
public
boolean
|
#
noop( )
Send an SMTP NOOP command. Used to keep keep-alives alive, doesn't actually
do anything
Send an SMTP NOOP command. Used to keep keep-alives alive, doesn't actually
do anything
Returns
boolean
|
public
boolean
|
#
turn( )
Send an SMTP TURN command. 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 <CRLF>
Send an SMTP TURN command. 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 <CRLF>
Returns
boolean
|
public
integer|boolean
|
#
client_send( string $data )
Send raw data to the server.
Send raw data to the server.
Parameters
- $data
string - $data The data to send
Returns
integer|boolean - The number of bytes sent to the server or false on error
|
public
array
|
#
getError( )
Get the latest error.
Returns
array
|
public
array|null
|
#
getServerExtList( )
Get SMTP extensions available on the server
Get SMTP extensions available on the server
Returns
array|null
|
public
mixed
|
#
getServerExt( string $name )
A multipurpose method The method works in three ways, dependent on argument
value and current state
1. HELO/EHLO was not sent - returns null and set up $this->error
2. HELO was sent
$name = 'HELO': returns server name
$name = 'EHLO': returns boolean false
$name = any string: returns null and set up $this->error
3. EHLO was sent
$name = 'HELO'|'EHLO': returns server name
$name = any string: if extension $name exists, returns boolean True
or its options. Otherwise returns boolean False In other words, one can use this
method to detect 3 conditions:
- null returned: handshake was not or we don't know about ext (refer to
$this->error)
- false returned: the requested feature exactly not exists
- positive value returned: the requested feature exists
A multipurpose method The method works in three ways, dependent on argument
value and current state 1. HELO/EHLO was not sent - returns null and set up
$this->error 2. HELO was sent $name = 'HELO': returns server name $name =
'EHLO': returns boolean false $name = any string: returns null and set up
$this->error 3. EHLO was sent $name = 'HELO'|'EHLO': returns server name
$name = any string: if extension $name exists, returns boolean True or its
options. Otherwise returns boolean False In other words, one can use this method
to detect 3 conditions: - null returned: handshake was not or we don't know
about ext (refer to $this->error) - false returned: the requested feature
exactly not exists - positive value returned: the requested feature exists
Parameters
- $name
string - $name Name of SMTP extension or 'HELO'|'EHLO'
Returns
mixed
|
public
string
|
#
getLastReply( )
Get the last reply from the server.
Get the last reply from the server.
Returns
string
|
protected
string
|
#
get_lines( )
Read the SMTP server's response. 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.
Read the SMTP server's response. 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.
Returns
string
|
public
|
#
setVerp( boolean $enabled = false )
Enable or disable VERP address generation.
Enable or disable VERP address generation.
Parameters
- $enabled
boolean - $enabled
|
public
boolean
|
#
getVerp( )
Get VERP address generation mode.
Get VERP address generation mode.
Returns
boolean
|
protected
|
#
setError( string $message, string $detail = '', string $smtp_code = '', string $smtp_code_ex = '' )
Set error messages and codes.
Set error messages and codes.
Parameters
- $message
string - $message The error message
- $detail
string - $detail Further detail on the error
- $smtp_code
string - $smtp_code An associated SMTP error code
- $smtp_code_ex
string - $smtp_code_ex Extended SMTP code
|
public
|
#
setDebugOutput( string|callable $method = 'echo' )
Set debug output method.
Parameters
- $method
string|callable - $method The name of the mechanism to use for debugging output, or a callable to
handle it.
|
public
string
|
|
public
|
#
setDebugLevel( integer $level = 0 )
Set debug output level.
Parameters
|
public
integer
|
|
public
|
#
setTimeout( integer $timeout = 0 )
Set SMTP timeout.
Parameters
- $timeout
integer - $timeout
|
public
integer
|
|
protected
|
#
errorHandler( integer $errno, string $errmsg, string $errfile = '', integer $errline = 0 )
Reports an error number and string.
Reports an error number and string.
Parameters
- $errno
integer - $errno The error number returned by PHP.
- $errmsg
string - $errmsg The error message returned by PHP.
- $errfile
string - $errfile The file the error occurred in
- $errline
integer - $errline The line number the error occurred on
|
public
boolean|null|string
|
#
getLastTransactionID( )
Will return the ID of the last smtp transaction based on a list of patterns
provided in SMTP::$smtp_transaction_id_patterns. If no reply has been received
yet, it will return null. If no pattern has been matched, it will return
false.
Will return the ID of the last smtp transaction based on a list of patterns
provided in SMTP::$smtp_transaction_id_patterns. If no reply has been received
yet, it will return null. If no pattern has been matched, it will return
false.
Returns
boolean|null|string
|
public
string
|
$Version
|
#
The PHPMailer SMTP Version number.
The PHPMailer SMTP Version number.
Deprecated
Use the VERSION constant instead
See
|
public
integer
|
$SMTP_PORT
|
#
SMTP server port number.
Deprecated
This is only ever used as a default value, so use the
DEFAULT_SMTP_PORT constant instead
See
|
public
string
|
$CRLF
|
#
SMTP reply line ending.
Deprecated
Use the CRLF constant instead
See
|
public
integer
|
$do_debug
|
#
Debug output level. Options:
- self::DEBUG_OFF (
0 ) No debug output, default
- self::DEBUG_CLIENT (
1 ) Client commands
- self::DEBUG_SERVER (
2 ) Client commands and server
responses
- self::DEBUG_CONNECTION (
3 ) As DEBUG_SERVER plus connection
status
- self::DEBUG_LOWLEVEL (
4 ) Low-level data output, all
messages
Debug output level. Options:
- self::DEBUG_OFF (
0 ) No debug output, default
- self::DEBUG_CLIENT (
1 ) Client commands
- self::DEBUG_SERVER (
2 ) Client commands and server
responses
- self::DEBUG_CONNECTION (
3 ) As DEBUG_SERVER plus connection
status
- self::DEBUG_LOWLEVEL (
4 ) Low-level data output, all
messages
|
public
string|callable
|
$Debugoutput
|
#
How to handle debug output. Options:
echo Output plain-text as-is, appropriate for CLI
html Output escaped, line breaks converted to
<br> , appropriate for browser output
error_log Output to error log as configured in php.ini
How to handle debug output. Options:
echo Output plain-text as-is, appropriate for CLI
html Output escaped, line breaks converted to
<br> , appropriate for browser output
error_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";};
|
public
boolean
|
$do_verp
|
#
Whether to use VERP.
Link
|
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.
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.
Link
|
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
How long to wait for commands to complete, in seconds. Default of 5 minutes
(300sec) is from RFC2821 section 4.5.3.2
|
protected
array
|
$smtp_transaction_id_patterns
|
#
patterns to extract smtp transaction id from smtp reply Only first capture
group will be use, use non-capturing group to deal with it Extend this class to
override this property to fulfil your needs.
patterns to extract smtp transaction id from smtp reply Only first capture
group will be use, use non-capturing group to deal with it Extend this class to
override this property to fulfil your needs.
|
protected
resource
|
$smtp_conn
|
#
The socket for the server connection.
The socket for the server connection.
|
protected
array
|
$error
|
#
Error information, if any, for the last SMTP command.
Error information, if any, for the last SMTP command.
|
protected
string|null
|
$helo_rply
|
#
The reply the server sent to us for HELO. If null, no HELO string has yet
been received.
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.
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.
The most recent reply received from the server.
|