Net_SMTP
[ class tree: Net_SMTP ] [ index: Net_SMTP ] [ all elements ]

Class: Net_SMTP

Source Location: /Net_SMTP-1.7.2/Net/SMTP.php

Class Overview


Provides an implementation of the SMTP protocol using PEAR's Net_Socket class.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 35]
Provides an implementation of the SMTP protocol using PEAR's Net_Socket class.


[ Top ]


Class Variables

$arguments = array()

[line 120]

The most recent server response arguments.
  • Access: protected

Type:   array


[ Top ]

$auth_methods = array()

[line 59]

List of supported authentication methods, in preferential order.
  • Access: public

Type:   array


[ Top ]

$code =  -1

[line 114]

The most recent server response code.
  • Access: protected

Type:   int


[ Top ]

$debug =  false

[line 83]

Should debugging output be enabled?
  • Access: protected

Type:   boolean


[ Top ]

$debug_handler =  null

[line 89]

Debug output handler.
  • Access: protected

Type:   callback


[ Top ]

$esmtp = array()

[line 132]

Stores detected features of the SMTP server.
  • Access: protected

Type:   array


[ Top ]

$greeting =  null

[line 126]

Stores the SMTP server's greeting string.
  • Access: protected

Type:   string


[ Top ]

$host =  'localhost'

[line 41]

The server to connect to.
  • Access: public

Type:   string


[ Top ]

$localhost =  'localhost'

[line 53]

The value to give when sending EHLO or HELO.
  • Access: public

Type:   string


[ Top ]

$pipelined_commands =  0

[line 77]

Number of pipelined commands.
  • Access: protected

Type:   int


[ Top ]

$pipelining =  false

[line 71]

Use SMTP command pipelining (specified in RFC 2920) if the SMTP server supports it.

When pipeling is enabled, rcptTo(), mailFrom(), sendFrom(), somlFrom() and samlFrom() do not wait for a response from the SMTP server but return immediately.

  • Access: public

Type:   bool


[ Top ]

$port =  25

[line 47]

The port to connect to.
  • Access: public

Type:   int


[ Top ]

$socket =  null

[line 95]

The socket resource being used to connect to the SMTP server.
  • Access: protected

Type:   resource


[ Top ]

$socket_options =  null

[line 102]

Array of socket options that will be passed to Net_Socket::connect().

Type:   array


[ Top ]

$timeout =  0

[line 108]

The socket I/O timeout value in seconds.
  • Access: protected

Type:   int


[ Top ]



Method Detail

__construct (Constructor)   [line 154]

Net_SMTP __construct( [string $host = null], [integer $port = null], [string $localhost = null], [boolean $pipelining = false], [integer $timeout = 0], [array $socket_options = null])

Instantiates a new Net_SMTP object, overriding any defaults with parameters that are passed in.

If you have SSL support in PHP, you can connect to a server over SSL using an 'ssl://' prefix:

// 465 is a common smtps port. $smtp = new Net_SMTP('ssl://mail.host.com', 465); $smtp->connect();

  • Since: 1.0
  • Access: public

Parameters:

string   $host   —  The server to connect to.
integer   $port   —  The port to connect to.
string   $localhost   —  The value to give when sending EHLO or HELO.
boolean   $pipelining   —  Use SMTP command pipelining
integer   $timeout   —  Socket I/O timeout in seconds.
array   $socket_options   —  Socket stream_context_create() options.

[ Top ]

auth   [line 557]

mixed auth( string $uid, string $pwd, [string $method = ''], [bool $tls = true], [string $authz = ''])

Attempt to do SMTP authentication.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

Parameters:

string   $uid   —  The userid to authenticate as.
string   $pwd   —  The password to authenticate with.
string   $method   —  The requested authentication method. If none is specified, the best supported method will be used.
bool   $tls   —  Flag indicating whether or not TLS should be attempted.
string   $authz   —  An optional authorization identifier. If specified, this identifier will be used as the authorization proxy.

[ Top ]

authCRAMMD5   [line 741]

mixed authCRAMMD5( string $uid, string $pwd, [string $authz = ''])

Authenticates the user using the CRAM-MD5 method.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.1.0
  • Access: protected

Parameters:

string   $uid   —  The userid to authenticate as.
string   $pwd   —  The password to authenticate with.
string   $authz   —  The optional authorization proxy identifier.

[ Top ]

authDigestMD5   [line 690]

mixed authDigestMD5( string $uid, string $pwd, [string $authz = ''])

Authenticates the user using the DIGEST-MD5 method.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.1.0
  • Access: protected

Parameters:

string   $uid   —  The userid to authenticate as.
string   $pwd   —  The password to authenticate with.
string   $authz   —  The optional authorization proxy identifier.

[ Top ]

authLogin   [line 780]

mixed authLogin( string $uid, string $pwd, [string $authz = ''])

Authenticates the user using the LOGIN method.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.1.0
  • Access: protected

Parameters:

string   $uid   —  The userid to authenticate as.
string   $pwd   —  The password to authenticate with.
string   $authz   —  The optional authorization proxy identifier.

[ Top ]

authPlain   [line 825]

mixed authPlain( string $uid, string $pwd, [string $authz = ''])

Authenticates the user using the PLAIN method.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.1.0
  • Access: protected

Parameters:

string   $uid   —  The userid to authenticate as.
string   $pwd   —  The password to authenticate with.
string   $authz   —  The optional authorization proxy identifier.

[ Top ]

command   [line 364]

mixed command( string $command, mixed $valid)

Issue an SMTP command and verify its response.
  • Return: True on success or a PEAR_Error object on failure.
  • Since: 1.6.0
  • Access: public

Parameters:

string   $command   —  The SMTP command string or data.
mixed   $valid   —  The set of valid response codes. These may be specified as an array of integer values or as a single integer value.

[ Top ]

connect   [line 415]

mixed connect( [int $timeout = null], [bool $persistent = false])

Attempt to connect to the SMTP server.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

Parameters:

int   $timeout   —  The timeout value (in seconds) for the socket connection attempt.
bool   $persistent   —  Should a persistent socket connection be used?

[ Top ]

data   [line 991]

mixed data( mixed $data, [string $headers = null])

Send the DATA command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

Parameters:

mixed   $data   —  The message data, either as a string or an open file resource.
string   $headers   —  The message headers. If $headers is provided, $data is assumed to contain only body data.

[ Top ]

debug   [line 218]

void debug( string $message)

Write the given debug text to the current debug output handler.
  • Since: 1.3.3
  • Access: protected

Parameters:

string   $message   —  Debug mesage text.

[ Top ]

disconnect   [line 462]

mixed disconnect( )

Attempt to disconnect from the SMTP server.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

[ Top ]

getBestAuthMethod   [line 529]

mixed getBestAuthMethod( )

Returns the name of the best authentication method that the server has advertised.
  • Return: Returns a string containing the name of the best supported authentication method or a PEAR_Error object if a failure condition is encountered.
  • Since: 1.1.0
  • Access: protected

[ Top ]

getGreeting   [line 398]

string getGreeting( )

Return the SMTP server's greeting string.
  • Return: A string containing the greeting string, or null if a greeting has not been received.
  • Since: 1.3.3
  • Access: public

[ Top ]

getResponse   [line 385]

array getResponse( )

Return a 2-tuple containing the last response from the SMTP server.
  • Return: A two-element array: the first element contains the response code as an integer and the second element contains the response's arguments as a string.
  • Since: 1.1.0
  • Access: public

[ Top ]

getServiceExtensions   [line 880]

array getServiceExtensions( )

Return the list of SMTP service extensions advertised by the server.
  • Return: The list of SMTP service extensions.
  • Since: 1.3
  • Access: public

[ Top ]

helo   [line 862]

mixed helo( string $domain)

Send the HELO command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

Parameters:

string   $domain   —  The domain name to say we are.

[ Top ]

identifySender   [line 1250]

boolean identifySender( )

Backwards-compatibility method. identifySender()'s functionality is now handled internally.
  • Return: This method always return true.
  • Since: 1.0
  • Access: public

[ Top ]

mailFrom   [line 903]

mixed mailFrom( string $sender, [string $params = null])

Send the MAIL FROM: command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

Parameters:

string   $sender   —  The sender (reverse path) to set.
string   $params   — 

String containing additional MAIL parameters, such as the NOTIFY flags defined by RFC 1891 or the VERP protocol.

If $params is an array, only the 'verp' option is supported. If 'verp' is true, the XVERP parameter is appended to the MAIL command. If the 'verp' value is a string, the full XVERP=value parameter is appended.


[ Top ]

negotiate   [line 488]

mixed negotiate( )

Attempt to send the EHLO command and obtain a list of ESMTP extensions available, and failing that just send HELO.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.1.0
  • Access: protected

[ Top ]

noop   [line 1230]

mixed noop( )

Send the NOOP command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

[ Top ]

parseResponse   [line 301]

mixed parseResponse( mixed $valid, [bool $later = false])

Read a reply from the SMTP server. The reply consists of a response code and a response message.
  • Return: True if the server returned a valid response code or a PEAR_Error object is an error condition is reached.
  • See: Net_SMTP::getResponse()
  • Since: 1.1.0
  • Access: protected

Parameters:

mixed   $valid   —  The set of valid response codes. These may be specified as an array of integer values or as a single integer value.
bool   $later   —  Do not parse the response now, but wait until the last command in the pipelined command group

[ Top ]

put   [line 270]

mixed put( string $command, [string $args = ''])

Send a command to the server with an optional string of

arguments. A carriage return / linefeed (CRLF) sequence will be appended to each command string before it is sent to the SMTP server - an error will be thrown if the command string already contains any newline characters. Use send() for commands that must contain newlines.

  • Return: The result of the send() call.
  • Since: 1.1.0
  • Access: protected

Parameters:

string   $command   —  The SMTP command to send to the server.
string   $args   —  A string of optional arguments to append to the command.

[ Top ]

quotedata   [line 969]

void quotedata( string &$data)

Quote the data so that it meets SMTP standards.

This is provided as a separate public function to facilitate easier overloading for the cases where it is desirable to customize the quoting behavior.

  • Since: 1.2
  • Access: public

Parameters:

string   &$data   —  The message text to quote. The string must be passed by reference, and the text will be modified in place.

[ Top ]

rcptTo   [line 940]

mixed rcptTo( string $recipient, [string $params = null])

Send the RCPT TO: command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

Parameters:

string   $recipient   —  The recipient (forward path) to add.
string   $params   —  String containing additional RCPT parameters, such as the NOTIFY flags defined by RFC 1891.

[ Top ]

rset   [line 1189]

mixed rset( )

Send the RSET command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

[ Top ]

samlFrom   [line 1170]

mixed samlFrom( string $path)

Send the SAML FROM: command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.2.6
  • Access: public

Parameters:

string   $path   —  The reverse path to send.

[ Top ]

send   [line 241]

mixed send( string $data)

Send the given string of data to the server.
  • Return: The number of bytes that were actually written, or a PEAR_Error object on failure.
  • Since: 1.1.0
  • Access: protected

Parameters:

string   $data   —  The string of data to send.

[ Top ]

sendFrom   [line 1128]

mixed sendFrom( string $path)

Send the SEND FROM: command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.2.6
  • Access: public

Parameters:

string   $path   —  The reverse path to send.

[ Top ]

setAuthMethod   [line 652]

mixed setAuthMethod( string $name, mixed $callback, [bool $prepend = true])

Add a new authentication method.
  • Return: True on success or a PEAR_Error object on failure.
  • Since: 1.6.0
  • Access: public

Parameters:

string   $name   —  The authentication method name (e.g. 'PLAIN')
mixed   $callback   —  The authentication callback (given as the name of a function or as an (object, method name) array).
bool   $prepend   —  Should the new method be prepended to the list of available methods? This is the default behavior, giving the new method the highest priority.

[ Top ]

setDebug   [line 205]

void setDebug( boolean $debug, [callback $handler = null])

Set the value of the debugging flag.
  • Since: 1.1.0
  • Access: public

Parameters:

boolean   $debug   —  New value for the debugging flag.
callback   $handler   —  Debug handler callback

[ Top ]

setTimeout   [line 192]

void setTimeout( integer $seconds, [integer $microseconds = 0])

Set the socket I/O timeout value in seconds plus microseconds.
  • Since: 1.5.0
  • Access: public

Parameters:

integer   $seconds   —  Timeout value in seconds.
integer   $microseconds   —  Additional value in microseconds.

[ Top ]

somlFrom   [line 1149]

mixed somlFrom( string $path)

Send the SOML FROM: command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.2.6
  • Access: public

Parameters:

string   $path   —  The reverse path to send.

[ Top ]

vrfy   [line 1210]

mixed vrfy( string $string)

Send the VRFY command.
  • Return: Returns a PEAR_Error with an error message on any kind of failure, or true on success.
  • Since: 1.0
  • Access: public

Parameters:

string   $string   —  The string to verify

[ Top ]


Documentation generated on Mon, 30 May 2016 01:00:03 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.