Joomla CMS  3.10.11 (avec JPlatform 13.1 inclus)
Documentation des API du CMS Joomla en version 3.10.11 et du framework Joomla Platform intégré
Référence de la classe SMTP

Fonctions membres publiques

 connect ($host, $port=null, $timeout=30, $options=array())
 
 startTLS ()
 
 authenticate ( $username, $password, $authtype=null, $realm='', $workstation='', $OAuth=null)
 
 connected ()
 
 close ()
 
 data ($msg_data)
 
 hello ($host='')
 
 mail ($from)
 
 quit ($close_on_error=true)
 
 recipient ($address)
 
 reset ()
 
 sendAndMail ($from)
 
 verify ($name)
 
 noop ()
 
 turn ()
 
 client_send ($data)
 
 getError ()
 
 getServerExtList ()
 
 getServerExt ($name)
 
 getLastReply ()
 
 setVerp ($enabled=false)
 
 getVerp ()
 
 setDebugOutput ($method='echo')
 
 getDebugOutput ()
 
 setDebugLevel ($level=0)
 
 getDebugLevel ()
 
 setTimeout ($timeout=0)
 
 getTimeout ()
 
 getLastTransactionID ()
 

Champs de données

const VERSION = '5.2.28'
 
const CRLF = "\r\n"
 
const DEFAULT_SMTP_PORT = 25
 
const MAX_LINE_LENGTH = 998
 
const DEBUG_OFF = 0
 
const DEBUG_CLIENT = 1
 
const DEBUG_SERVER = 2
 
const DEBUG_CONNECTION = 3
 
const DEBUG_LOWLEVEL = 4
 
 $Version = '5.2.28'
 
 $SMTP_PORT = 25
 
 $CRLF = "\r\n"
 
 $do_debug = self::DEBUG_OFF
 
 $Debugoutput = 'echo'
 
 $do_verp = false
 
 $Timeout = 300
 
 $Timelimit = 300
 

Fonctions membres protégées

 edebug ($str, $level=0)
 
 hmac ($data, $key)
 
 sendHello ($hello, $host)
 
 parseHelloFields ($type)
 
 sendCommand ($command, $commandstring, $expect)
 
 get_lines ()
 
 setError ($message, $detail='', $smtp_code='', $smtp_code_ex='')
 
 errorHandler ($errno, $errmsg, $errfile='', $errline=0)
 
 recordLastTransactionID ()
 

Attributs protégés

 $smtp_transaction_id_patterns
 
 $last_smtp_transaction_id
 
 $smtp_conn
 
 $error
 
 $helo_rply = null
 
 $server_caps = null
 
 $last_reply = ''
 

Documentation des fonctions membres

◆ authenticate()

authenticate (   $username,
  $password,
  $authtype = null,
  $realm = '',
  $workstation = '',
  $OAuth = null 
)

Perform SMTP authentication. Must be run after hello().

Voir également
hello()
Paramètres
string$usernameThe user name
string$passwordThe password
string$authtypeThe auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2)
string$realmThe auth realm for NTLM
string$workstationThe auth workstation for NTLM
null | OAuth$OAuthAn optional OAuth instance (
Voir également
PHPMailerOAuth)
Renvoie
bool True if successfully authenticated.* public

Références $msg1, $password, edebug(), elseif, hmac(), sendCommand(), et setError().

◆ client_send()

client_send (   $data)

Send raw data to the server.

Paramètres
string$dataThe data to send public
Renvoie
integer|boolean The number of bytes sent to the server or false on error

Références $data, et edebug().

Référencé par data(), et sendCommand().

◆ close()

close ( )

Close the socket and clean up the state of the class. Don't use this function without first trying to use QUIT.

Voir également
quit() public
Renvoie
void

Références edebug(), null, et setError().

Référencé par connected(), et quit().

◆ connect()

connect (   $host,
  $port = null,
  $timeout = 30,
  $options = array() 
)

Connect to an SMTP server.

Paramètres
string$hostSMTP server IP or host name
integer$portThe port number to connect to
integer$timeoutHow long to wait for the connection to open
array$optionsAn array of options for stream_context_create() public
Renvoie
boolean

Références $options, connected(), edebug(), get_lines(), et setError().

◆ connected()

connected ( )

Check connection state. public

Renvoie
boolean True if connected.

Références close(), et edebug().

Référencé par connect(), et sendCommand().

◆ data()

data (   $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>

Paramètres
string$msg_dataMessage data to send public
Renvoie
boolean

Références $field, $Timelimit, client_send(), recordLastTransactionID(), et sendCommand().

◆ edebug()

edebug (   $str,
  $level = 0 
)
protected

Output debugging info via a user-selected method.

Voir également
SMTP::$Debugoutput
SMTP::$do_debug
Paramètres
string$strDebug string to output
integer$levelThe debug level of this message; see DEBUG_* constants
Renvoie
void

Références ENT_QUOTES.

Référencé par authenticate(), client_send(), close(), connect(), connected(), errorHandler(), get_lines(), sendCommand(), et turn().

◆ errorHandler()

errorHandler (   $errno,
  $errmsg,
  $errfile = '',
  $errline = 0 
)
protected

Reports an error number and string.

Paramètres
integer$errnoThe error number returned by PHP.
string$errmsgThe error message returned by PHP.
string$errfileThe file the error occurred in
integer$errlineThe line number the error occurred on

Références edebug(), et setError().

◆ get_lines()

get_lines ( )
protected

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. protected

Renvoie
string

Références $data, $info, $Timelimit, et edebug().

Référencé par connect(), et sendCommand().

◆ getDebugLevel()

getDebugLevel ( )

Get debug output level.

Renvoie
integer

Références $do_debug.

◆ getDebugOutput()

getDebugOutput ( )

Get debug output method.

Renvoie
string

Références $Debugoutput.

◆ getError()

getError ( )

Get the latest error. public

Renvoie
array

Références $error.

◆ getLastReply()

getLastReply ( )

Get the last reply from the server. public

Renvoie
string

Références $last_reply.

Référencé par recordLastTransactionID().

◆ getLastTransactionID()

getLastTransactionID ( )

Get the queue/transaction ID of the last SMTP transaction If no reply has been received yet, it will return null. If no pattern was matched, it will return false.

Renvoie
bool|null|string
Voir également
recordLastTransactionID()

Références $last_smtp_transaction_id.

◆ getServerExt()

getServerExt (   $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
    Paramètres
    string$nameName of SMTP extension or 'HELO'|'EHLO'
    Renvoie
    mixed

Références $name, null, et setError().

◆ getServerExtList()

getServerExtList ( )

Get SMTP extensions available on the server public

Renvoie
array|null

Références $server_caps.

◆ getTimeout()

getTimeout ( )

Get SMTP timeout.

Renvoie
integer

Références $Timeout.

◆ getVerp()

getVerp ( )

Get VERP address generation mode.

Renvoie
boolean

Références $do_verp.

◆ hello()

hello (   $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.

Paramètres
string$hostThe host name or IP to connect to public
Renvoie
boolean

Références sendHello().

◆ hmac()

hmac (   $data,
  $key 
)
protected

Calculate an MD5 HMAC hash. Works like hash_hmac('md5', $data, $key) in case that function is not available

Paramètres
string$dataThe data to hash
string$keyThe key to hash with protected
Renvoie
string

Références $data, et $key.

Référencé par authenticate().

◆ mail()

mail (   $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>

Paramètres
string$fromSource address of this message public
Renvoie
boolean

Références sendCommand().

◆ noop()

noop ( )

Send an SMTP NOOP command. Used to keep keep-alives alive, doesn't actually do anything public

Renvoie
boolean

Références sendCommand().

◆ parseHelloFields()

parseHelloFields (   $type)
protected

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. protected

Paramètres
string$type- 'HELO' or 'EHLO'

Références $fields, $n, $name, et $type.

Référencé par sendHello().

◆ quit()

quit (   $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>

Paramètres
boolean$close_on_errorShould the connection close if an error occurs? public
Renvoie
boolean

Références $error, close(), et sendCommand().

◆ recipient()

recipient (   $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>

Paramètres
string$addressThe address the message is being sent to public
Renvoie
boolean

Références sendCommand().

◆ recordLastTransactionID()

recordLastTransactionID ( )
protected

Extract and return the ID of the last SMTP transaction based on a list of patterns provided in SMTP::$smtp_transaction_id_patterns. 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.

Renvoie
bool|null|string

Références $last_smtp_transaction_id, getLastReply(), et null.

Référencé par data().

◆ reset()

reset ( )

Send an SMTP RSET command. Abort any transaction that is currently in progress. Implements rfc 821: RSET <CRLF> public

Renvoie
boolean True on success.

Références sendCommand().

◆ sendAndMail()

sendAndMail (   $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>

Paramètres
string$fromThe address the message is from public
Renvoie
boolean

Références sendCommand().

◆ sendCommand()

sendCommand (   $command,
  $commandstring,
  $expect 
)
protected

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

Paramètres
string$commandThe command name - not sent to the server
string$commandstringThe actual command to send
integer | array$expectOne or more expected integer success codes protected
Renvoie
boolean True on success.

Références client_send(), connected(), edebug(), get_lines(), null, et setError().

Référencé par authenticate(), data(), mail(), noop(), quit(), recipient(), reset(), sendAndMail(), sendHello(), startTLS(), et verify().

◆ sendHello()

sendHello (   $hello,
  $host 
)
protected

Send an SMTP HELO or EHLO command. Low-level implementation used by hello()

Voir également
hello()
Paramètres
string$helloThe HELO string
string$hostThe hostname to say we are protected
Renvoie
boolean

Références $last_reply, null, parseHelloFields(), et sendCommand().

Référencé par hello().

◆ setDebugLevel()

setDebugLevel (   $level = 0)

Set debug output level.

Paramètres
integer$level

◆ setDebugOutput()

setDebugOutput (   $method = 'echo')

Set debug output method.

Paramètres
string | callable$methodThe name of the mechanism to use for debugging output, or a callable to handle it.

◆ setError()

setError (   $message,
  $detail = '',
  $smtp_code = '',
  $smtp_code_ex = '' 
)
protected

Set error messages and codes.

Paramètres
string$messageThe error message
string$detailFurther detail on the error
string$smtp_codeAn associated SMTP error code
string$smtp_code_exExtended SMTP code

Références $message.

Référencé par authenticate(), close(), connect(), errorHandler(), getServerExt(), sendCommand(), et turn().

◆ setTimeout()

setTimeout (   $timeout = 0)

Set SMTP timeout.

Paramètres
integer$timeout

◆ setVerp()

setVerp (   $enabled = false)

Enable or disable VERP address generation.

Paramètres
boolean$enabled

Références $enabled.

◆ startTLS()

startTLS ( )

Initiate a TLS (encrypted) session. public

Renvoie
boolean

Références sendCommand().

◆ turn()

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> public

Renvoie
boolean

Références edebug(), et setError().

◆ verify()

verify (   $name)

Send an SMTP VRFY command.

Paramètres
string$nameThe name to verify public
Renvoie
boolean

Références sendCommand().

Documentation des champs

◆ $CRLF

$CRLF = "\r\n"

◆ $Debugoutput

$Debugoutput = 'echo'

Référencé par getDebugOutput().

◆ $do_debug

$do_debug = self::DEBUG_OFF

Référencé par getDebugLevel().

◆ $do_verp

$do_verp = false

Référencé par getVerp().

◆ $error

$error
protected
Valeur initiale :
= array(
'error' => '',
'detail' => '',
'smtp_code' => '',
'smtp_code_ex' => ''
)

Référencé par getError(), et quit().

◆ $helo_rply

$helo_rply = null
protected

◆ $last_reply

$last_reply = ''
protected

Référencé par getLastReply(), et sendHello().

◆ $last_smtp_transaction_id

$last_smtp_transaction_id
protected

◆ $server_caps

$server_caps = null
protected

Référencé par getServerExtList().

◆ $smtp_conn

$smtp_conn
protected

◆ $SMTP_PORT

$SMTP_PORT = 25

◆ $smtp_transaction_id_patterns

$smtp_transaction_id_patterns
protected
Valeur initiale :
= 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 (.*)/'
)

◆ $Timelimit

$Timelimit = 300

Référencé par data(), et get_lines().

◆ $Timeout

$Timeout = 300

Référencé par getTimeout().

◆ $Version

$Version = '5.2.28'

◆ CRLF

const CRLF = "\r\n"

◆ DEBUG_CLIENT

const DEBUG_CLIENT = 1

Debug level to show client -> server messages

◆ DEBUG_CONNECTION

const DEBUG_CONNECTION = 3

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

◆ DEBUG_LOWLEVEL

const DEBUG_LOWLEVEL = 4

Debug level to show all messages

◆ DEBUG_OFF

const DEBUG_OFF = 0

Debug level for no output

◆ DEBUG_SERVER

const DEBUG_SERVER = 2

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

◆ DEFAULT_SMTP_PORT

const DEFAULT_SMTP_PORT = 25

◆ MAX_LINE_LENGTH

const MAX_LINE_LENGTH = 998

◆ VERSION

const VERSION = '5.2.28'

La documentation de cette classe a été générée à partir du fichier suivant :