phpDocumentor PHPMailer
[ class tree: PHPMailer ] [ index: PHPMailer ] [ all elements ]

Class: SMTP

Source Location: /core/PHPMailer/class.smtp.php

Class SMTP

Constant Summary
CRLF   SMTP line break constant.
DEBUG_CLIENT   Debug level to show client -> server messages
DEBUG_CONNECTION   Debug level to show connection status, client -> server and server -> client messages
DEBUG_LOWLEVEL   Debug level to show all messages
DEBUG_OFF   Debug level for no output
DEBUG_SERVER   Debug level to show client -> server and server -> client messages
DEFAULT_SMTP_PORT   The SMTP port to use if one is not specified.
MAX_LINE_LENGTH   The maximum line length allowed by RFC 2822 section 2.1.1
VERSION   The PHPMailer SMTP version number.

[ Top ]
Property Summary
mixed   $CRLF   SMTP reply line ending.
mixed   $Debugoutput   How to handle debug output.
mixed   $do_debug   Debug output level.
mixed   $do_verp   Whether to use VERP.
mixed   $error   Error message, if any, for the last call.
mixed   $helo_rply   The reply the server sent to us for HELO.
mixed   $last_reply   The most recent reply received from the server.
mixed   $smtp_conn   The socket for the server connection.
mixed   $SMTP_PORT   SMTP server port number.
mixed   $Timelimit   The SMTP timelimit value for reads, in seconds.
mixed   $Timeout   The timeout value for connection, in seconds.
mixed   $Version   The PHPMailer SMTP Version number.

[ Top ]
Method Summary
boolean   authenticate()   Perform SMTP authentication.
integer|boolean   client_send()   Send raw data to the server.
void   close()   Close the socket and clean up the state of the class.
boolean   connect()   Connect to an SMTP server.
boolean   connected()   Check connection state.
boolean   data()   Send an SMTP DATA command.
void   edebug()   Output debugging info via a user-selected method.
integer   getDebugLevel()   Get debug output level.
string   getDebugOutput()   Get debug output method.
array   getError()   Get the latest error.
string   getLastReply()   Get the last reply from the server.
integer   getTimeout()   Get SMTP timeout.
boolean   getVerp()   Get VERP address generation mode.
string   get_lines()   Read the SMTP server's response.
boolean   hello()   Send an SMTP HELO or EHLO command.
string   hmac()   Calculate an MD5 HMAC hash.
boolean   mail()   Send an SMTP MAIL command.
boolean   noop()   Send an SMTP NOOP command.
boolean   quit()   Send an SMTP QUIT command.
boolean   recipient()   Send an SMTP RCPT command.
boolean   reset()   Send an SMTP RSET command.
boolean   sendAndMail()   Send an SMTP SAML command.
boolean   sendCommand()   Send a command to an SMTP server and check its return code.
boolean   sendHello()   Send an SMTP HELO or EHLO command.
void   setDebugLevel()   Set debug output level.
void   setDebugOutput()   Set debug output method.
void   setTimeout()   Set SMTP timeout.
void   setVerp()   Enable or disable VERP address generation.
boolean   startTLS()   Initiate a TLS (encrypted) session.
boolean   turn()   Send an SMTP TURN command.
boolean   verify()   Send an SMTP VRFY command.

[ Top ]
Properties
mixed   $CRLF = "\r\n" [line 100]

SMTP reply line ending.

API Tags:
See:  SMTP::CRLF
Deprecated:  Use the `CRLF` constant instead
Access:  public


[ Top ]
mixed   $Debugoutput = 'echo' [line 127]

How to handle debug output.

Options: * `echo` Output plain-text as-is, appropriate for CLI * `html` Output escaped, line breaks converted to `
`, 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:

  1.  $smtp->Debugoutput function($str$level{echo "debug level $level; message: $str";};

API Tags:
Access:  public


[ Top ]
mixed   $do_debug = self::DEBUG_OFF [line 112]

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

API Tags:
Access:  public


[ Top ]
mixed   $do_verp = false [line 135]

Whether to use VERP.

API Tags:
Access:  public

Information Tags:
Link:  http://en.wikipedia.org/wiki/Variable_envelope_return_path
Link:  Info on VERP

[ Top ]
mixed   $error = array() [line 162]

Error message, if any, for the last call.

API Tags:
Access:  protected


[ Top ]
mixed   $helo_rply = null [line 169]

The reply the server sent to us for HELO.

If null, no HELO string has yet been received.

API Tags:
Access:  protected


[ Top ]
mixed   $last_reply = '' [line 175]

The most recent reply received from the server.

API Tags:
Access:  protected


[ Top ]
mixed   $smtp_conn [line 156]

The socket for the server connection.

API Tags:
Access:  protected


[ Top ]
mixed   $SMTP_PORT = 25 [line 92]

SMTP server port number.

API Tags:
See:  SMTP::DEFAULT_SMTP_PORT
Deprecated:  This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead
Access:  public


[ Top ]
mixed   $Timelimit = 30 [line 150]

The SMTP timelimit value for reads, in seconds.

API Tags:
Access:  public


[ Top ]
mixed   $Timeout = 300 [line 144]

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.

API Tags:
Access:  public

Information Tags:
Link:  http://tools.ietf.org/html/rfc2821#section-4.5.3.2

[ Top ]
mixed   $Version = '5.2.9' [line 84]

The PHPMailer SMTP Version number.

API Tags:
See:  SMTP::VERSION
Deprecated:  Use the `VERSION` constant instead
Access:  public


[ Top ]
Methods
authenticate  [line 343]

  boolean authenticate( string $username, string $password, [string $authtype = 'LOGIN'], [string $realm = ''], [string $workstation = '']  )

Perform SMTP authentication.

Must be run after hello().

Parameters:
string   $username:  The user name
string   $password:  The password
string   $authtype:  The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5)
string   $realm:  The auth realm for NTLM
string   $workstation:  The auth workstation for NTLM

API Tags:
Return:  True if successfully authenticated.
See:  SMTP::hello()
Access:  public


[ Top ]
client_send  [line 816]

  integer|boolean client_send( string $data  )

Send raw data to the server.

Parameters:
string   $data:  The data to send

API Tags:
Return:  The number of bytes sent to the server or false on error
Access:  public


[ Top ]
close  [line 514]

  void close( )

Close the socket and clean up the state of the class.

Don't use this function without first trying to use QUIT.


API Tags:
See:  SMTP::quit()
Access:  public


[ Top ]
connect  [line 229]

  boolean connect( string $host, [integer $port = null], [integer $timeout = 30], [array $options = array()]  )

Connect to an SMTP server.

Parameters:
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()

API Tags:
Access:  public


[ Top ]
connected  [line 489]

  boolean connected( )

Check connection state.


API Tags:
Return:  True if connected.
Access:  public


[ Top ]
data  [line 538]

  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>

Parameters:
string   $msg_data:  Message data to send

API Tags:
Access:  public


[ Top ]
edebug  [line 185]

  void edebug( string $str, [integer $level = 0]  )

Output debugging info via a user-selected method.

Parameters:
string   $str:  Debug string to output
integer   $level:  The debug level of this message; see DEBUG_* constants

API Tags:
See:  SMTP::$Debugoutput
See:  SMTP::$do_debug
Access:  protected


[ Top ]
getDebugLevel  [line 944]

  integer getDebugLevel( )

Get debug output level.


API Tags:
Access:  public


[ Top ]
getDebugOutput  [line 926]

  string getDebugOutput( )

Get debug output method.


API Tags:
Access:  public


[ Top ]
getError  [line 827]

  array getError( )

Get the latest error.


API Tags:
Access:  public


[ Top ]
getLastReply  [line 837]

  string getLastReply( )

Get the last reply from the server.


API Tags:
Access:  public


[ Top ]
getTimeout  [line 962]

  integer getTimeout( )

Get SMTP timeout.


API Tags:
Access:  public


[ Top ]
getVerp  [line 908]

  boolean getVerp( )

Get VERP address generation mode.


API Tags:
Access:  public


[ Top ]
get_lines  [line 851]

  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.


API Tags:
Access:  protected


[ Top ]
hello  [line 620]

  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.

Parameters:
string   $host:  The host name or IP to connect to

API Tags:
Access:  public


[ Top ]
hmac  [line 457]

  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

Parameters:
string   $data:  The data to hash
string   $key:  The key to hash with

API Tags:
Access:  protected


[ Top ]
mail  [line 653]

  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>

Parameters:
string   $from:  Source address of this message

API Tags:
Access:  public


[ Top ]
noop  [line 787]

  boolean noop( )

Send an SMTP NOOP command.

Used to keep keep-alives alive, doesn't actually do anything


API Tags:
Access:  public


[ Top ]
quit  [line 671]

  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>

Parameters:
boolean   $close_on_error:  Should the connection close if an error occurs?

API Tags:
Access:  public


[ Top ]
recipient  [line 691]

  boolean recipient( string $toaddr  )

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:
string   $toaddr:  The address the message is being sent to

API Tags:
Access:  public


[ Top ]
reset  [line 707]

  boolean reset( )

Send an SMTP RSET command.

Abort any transaction that is currently in progress. Implements rfc 821: RSET <CRLF>


API Tags:
Return:  True on success.
Access:  public


[ Top ]
sendAndMail  [line 765]

  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>

Parameters:
string   $from:  The address the message is from

API Tags:
Access:  public


[ Top ]
sendCommand  [line 720]

  boolean sendCommand( string $command, string $commandstring, integer|array $expect  )

Send a command to an SMTP server and check its return code.

Parameters:
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

API Tags:
Return:  True on success.
Access:  protected


[ Top ]
sendHello  [line 635]

  boolean sendHello( string $hello, string $host  )

Send an SMTP HELO or EHLO command.

Low-level implementation used by hello()

Parameters:
string   $hello:  The HELO string
string   $host:  The hostname to say we are

API Tags:
See:  SMTP::hello()
Access:  protected


[ Top ]
setDebugLevel  [line 935]

  void setDebugLevel( [integer $level = 0]  )

Set debug output level.

Parameters:
integer   $level: 

API Tags:
Access:  public


[ Top ]
setDebugOutput  [line 917]

  void setDebugOutput( [string $method = 'echo']  )

Set debug output method.

Parameters:
string   $method:  The function/method to use for debugging output.

API Tags:
Access:  public


[ Top ]
setTimeout  [line 953]

  void setTimeout( [integer $timeout = 0]  )

Set SMTP timeout.

Parameters:
integer   $timeout: 

API Tags:
Access:  public


[ Top ]
setVerp  [line 899]

  void setVerp( [boolean $enabled = false]  )

Enable or disable VERP address generation.

Parameters:
boolean   $enabled: 

API Tags:
Access:  public


[ Top ]
startTLS  [line 315]

  boolean startTLS( )

Initiate a TLS (encrypted) session.


API Tags:
Access:  public


[ Top ]
turn  [line 801]

  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>


API Tags:
Access:  public


[ Top ]
verify  [line 776]

  boolean verify( string $name  )

Send an SMTP VRFY command.

Parameters:
string   $name:  The name to verify

API Tags:
Access:  public


[ Top ]
Constants
CRLF = "\r\n" [line 39]

SMTP line break constant.


[ Top ]
DEBUG_CLIENT = 1 [line 61]

Debug level to show client -> server messages


[ Top ]
DEBUG_CONNECTION = 3 [line 71]

Debug level to show connection status, client -> server and server -> client messages


[ Top ]
DEBUG_LOWLEVEL = 4 [line 76]

Debug level to show all messages


[ Top ]
DEBUG_OFF = 0 [line 56]

Debug level for no output


[ Top ]
DEBUG_SERVER = 2 [line 66]

Debug level to show client -> server and server -> client messages


[ Top ]
DEFAULT_SMTP_PORT = 25 [line 45]

The SMTP port to use if one is not specified.


[ Top ]
MAX_LINE_LENGTH = 998 [line 51]

The maximum line length allowed by RFC 2822 section 2.1.1


[ Top ]
VERSION = '5.2.9' [line 33]

The PHPMailer SMTP version number.


[ Top ]

Documentation generated on Tue, 06 Oct 2015 06:11:16 +0000 by phpDocumentor 1.4.4