Class SMTP

Description

PHPMailer RFC821 SMTP email transport class.

Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.

PHP Version 5.0.0

Located in /class.smtp.php (line 34)


	
			
Class Constant Summary
CRLF = "\r\n"
VERSION = '5.2.7'
Variable Summary
mixed $CRLF
mixed $Debugoutput
mixed $do_debug
mixed $do_verp
mixed $error
mixed $helo_rply
mixed $last_reply
mixed $smtp_conn
mixed $SMTP_PORT
mixed $Timelimit
mixed $Timeout
mixed $Version
Method Summary
SMTP __construct ()
bool authenticate (string $username, string $password, [string $authtype = 'LOGIN'], [string $realm = ''], [string $workstation = ''])
int|bool client_send (string $data)
void close ()
bool connect (string $host, [int $port = null], [int $timeout = 30], [array $options = array()])
bool connected ()
bool data (string $msg_data)
void edebug (string $str)
int getDebugLevel ()
string getDebugOutput ()
array getError ()
string getLastReply ()
int getTimeout ()
bool getVerp ()
string get_lines ()
bool hello ([string $host = ''])
string hmac (string $data, string $key)
bool mail (string $from)
bool noop ()
bool quit ([bool $close_on_error = true])
bool recipient (string $to)
bool reset ()
bool sendAndMail (string $from)
bool sendCommand (string $command, string $commandstring, int|array $expect)
bool sendHello (string $hello, string $host)
void setDebugLevel ([int $level = 0])
void setDebugOutput ([string $method = 'echo'])
void setTimeout ([int $timeout = 0])
void setVerp ([bool $enabled = false])
bool startTLS ()
bool turn ()
bool verify (string $name)
Variables
mixed $CRLF = "\r\n" (line 73)

SMTP reply line ending

  • see: SMTP::CRLF
  • deprecated: Use the class constant instead
  • access: public
mixed $Debugoutput = 'echo' (line 87)

The function/method to use for debugging output.

Options: 'echo', 'html' or 'error_log'

  • access: public
mixed $do_debug = 0 (line 80)

Debug output level.

Options: 0 for no output, 1 for commands, 2 for data and commands

  • access: public
mixed $do_verp = false (line 93)

Whether to use VERP.

  • access: public
mixed $error = '' (line 117)

Error message, if any, for the last call.

  • access: protected
mixed $helo_rply = '' (line 123)

The reply the server sent to us for HELO.

  • access: protected
mixed $last_reply = '' (line 129)

The most recent reply received from the server.

  • access: protected
mixed $smtp_conn (line 111)

The socket for the server connection.

  • access: protected
mixed $SMTP_PORT = 25 (line 65)

SMTP server port number.

  • see: SMTP::DEFAULT_SMTP_PORT
  • deprecated: This is only ever ued as default value, so should be a constant
  • access: public
mixed $Timelimit = 30 (line 105)

The SMTP timelimit value for reads, in seconds.

  • access: public
mixed $Timeout = 15 (line 99)

The SMTP timeout value for reads, in seconds.

  • access: public
mixed $Version = '5.2.7' (line 57)

The PHPMailer SMTP Version number.

  • see: SMTP::VERSION
  • deprecated: This should be a constant
  • access: public
Methods
Constructor __construct (line 135)

Constructor.

  • access: public
SMTP __construct ()
authenticate (line 281)

Perform SMTP authentication.

Must be run after hello().

  • return: True if successfully authenticated.
  • see: SMTP::hello()
  • access: public
bool authenticate (string $username, string $password, [string $authtype = 'LOGIN'], [string $realm = ''], [string $workstation = ''])
  • 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
client_send (line 783)

Send raw data to the server.

  • return: The number of bytes sent to the server or FALSE on error
  • access: public
int|bool client_send (string $data)
  • string $data: The data to send
close (line 458)

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

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

void close ()
connect (line 181)

Connect to an SMTP server.

  • access: public
bool connect (string $host, [int $port = null], [int $timeout = 30], [array $options = array()])
  • string $host: SMTP server IP or host name
  • int $port: The port number to connect to
  • int $timeout: How long to wait for the connection to open
  • array $options: An array of options for stream_context_create()
connected (line 432)

Check connection state.

  • return: True if connected.
  • access: public
bool connected ()
data (line 481)

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>

  • access: public
bool data (string $msg_data)
  • string $msg_data: Message data to send
edebug (line 149)

Output debugging info via a user-selected method.

  • access: protected
void edebug (string $str)
  • string $str: Debug string to output
getDebugLevel (line 921)

Get debug output level.

  • access: public
int getDebugLevel ()
getDebugOutput (line 903)

Get debug output method.

  • access: public
string getDebugOutput ()
getError (line 796)

Get the latest error.

  • access: public
array getError ()
getLastReply (line 806)

Get the last reply from the server.

  • access: public
string getLastReply ()
getTimeout (line 939)

Get SMTP timeout.

  • access: public
int getTimeout ()
getVerp (line 885)

Get VERP address generation mode.

  • access: public
bool getVerp ()
get_lines (line 820)

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.

  • access: protected
string get_lines ()
hello (line 574)

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 from RFC 821: HELO <SP> <domain> <CRLF> and RFC 2821 EHLO.

  • access: public
bool hello ([string $host = ''])
  • string $host: The host name or IP to connect to
hmac (line 400)

Calculate an MD5 HMAC hash.

Works like hash_hmac('md5', $data, $key) in case that function is not available

  • access: protected
string hmac (string $data, string $key)
  • string $data: The data to hash
  • string $key: The key to hash with
mail (line 613)

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>

  • access: public
bool mail (string $from)
  • string $from: Source address of this message
noop (line 752)

Send an SMTP NOOP command.

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

  • access: public
bool noop ()
quit (line 631)

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>

  • access: public
bool quit ([bool $close_on_error = true])
  • bool $close_on_error: Should the connection close if an error occurs?
recipient (line 651)

Send an SMTP RCPT command.

Sets the TO argument to $to. Returns true if the recipient was accepted false if it was rejected. Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>

  • access: public
bool recipient (string $to)
  • string $to: The address the message is being sent to
reset (line 667)

Send an SMTP RSET command.

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

  • return: True on success.
  • access: public
bool reset ()
sendAndMail (line 730)

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>

  • access: public
bool sendAndMail (string $from)
  • string $from: The address the message is from
sendCommand (line 680)

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

  • return: True on success.
  • access: protected
bool sendCommand (string $command, string $commandstring, int|array $expect)
  • string $command: The command name - not sent to the server
  • string $commandstring: The actual command to send
  • int|array $expect: One or more expected integer success codes
sendHello (line 595)

Send an SMTP HELO or EHLO command.

Low-level implementation used by hello()

bool sendHello (string $hello, string $host)
  • string $hello: The HELO string
  • string $host: The hostname to say we are
setDebugLevel (line 912)

Set debug output level.

  • access: public
void setDebugLevel ([int $level = 0])
  • int $level
setDebugOutput (line 894)

Set debug output method.

  • access: public
void setDebugOutput ([string $method = 'echo'])
  • string $method: The function/method to use for debugging output.
setTimeout (line 930)

Set SMTP timeout.

  • access: public
void setTimeout ([int $timeout = 0])
  • int $timeout
setVerp (line 876)

Enable or disable VERP address generation.

  • access: public
void setVerp ([bool $enabled = false])
  • bool $enabled
startTLS (line 252)

Initiate a TLS (encrypted) session.

  • access: public
bool startTLS ()
turn (line 766)

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>

  • access: public
bool turn ()
verify (line 741)

Send an SMTP VRFY command.

  • access: public
bool verify (string $name)
  • string $name: The name to verify
Class Constants
CRLF = "\r\n" (line 44)

SMTP line break constant.

DEFAULT_SMTP_PORT = 25 (line 49)

The SMTP port to use if one is not specified.

VERSION = '5.2.7' (line 39)

The PHPMailer SMTP Version number.

Documentation generated on Sat, 09 Nov 2013 23:19:24 +0100 by phpDocumentor 1.4.4