Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe SMTP

Fonctions membres publiques

 connect ($host, $port=null, $timeout=30, $options=[])
 
 startTLS ()
 
 authenticate ( $username, $password, $authtype=null, $OAuth=null)
 
 connected ()
 
 close ()
 
 data ($msg_data)
 
 hello ($host='')
 
 mail ($from)
 
 quit ($close_on_error=true)
 
 recipient ($address, $dsn='')
 
 reset ()
 
 sendAndMail ($from)
 
 verify ($name)
 
 noop ()
 
 turn ()
 
 client_send ($data, $command='')
 
 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 = '6.6.0'
 
const LE = "\r\n"
 
const DEFAULT_PORT = 25
 
const MAX_LINE_LENGTH = 998
 
const MAX_REPLY_LENGTH = 512
 
const DEBUG_OFF = 0
 
const DEBUG_CLIENT = 1
 
const DEBUG_SERVER = 2
 
const DEBUG_CONNECTION = 3
 
const DEBUG_LOWLEVEL = 4
 
 $do_debug = self::DEBUG_OFF
 
 $Debugoutput = 'echo'
 
 $do_verp = false
 
 $Timeout = 300
 
 $Timelimit = 300
 

Fonctions membres protégées

 edebug ($str, $level=0)
 
 getSMTPConnection ($host, $port=null, $timeout=30, $options=[])
 
 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
 
 $server_caps
 
 $last_reply = ''
 

Description détaillée

PHPMailer RFC821 SMTP email transport class. Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.

Auteur
Chris Ryan
Marcus Bointon phpma.nosp@m.iler.nosp@m.@sync.nosp@m.hrom.nosp@m.edia..nosp@m.co.u.nosp@m.k

Documentation des fonctions membres

◆ authenticate()

authenticate (   $username,
  $password,
  $authtype = null,
  $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 (CRAM-MD5, PLAIN, LOGIN, XOAUTH2)
OAuthTokenProvider$OAuthAn optional OAuthTokenProvider instance for XOAUTH2 authentication
Renvoie
bool True if successfully authenticated

Références $method, $password, SMTP\edebug(), elseif, SMTP\hmac(), null, SMTP\sendCommand(), et SMTP\setError().

◆ client_send()

client_send (   $data,
  $command = '' 
)

Send raw data to the server.

Paramètres
string$dataThe data to send
string$commandOptionally, the command this is part of, used only for controlling debug output
Renvoie
int|bool The number of bytes sent to the server or false on error

Références $data, $result, $this, et SMTP\edebug().

Référencé par SMTP\data(), et SMTP\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()

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

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

◆ connect()

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

Connect to an SMTP server.

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

Références $options, SMTP\close(), SMTP\connected(), SMTP\edebug(), SMTP\get_lines(), SMTP\getSMTPConnection(), SMTP\quit(), et SMTP\setError().

◆ connected()

connected ( )

Check connection state.

Renvoie
bool True if connected

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

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

◆ data()

data (   $msg_data)

Send an SMTP DATA command. Issues a data command and sends the msg_data to the server, finalizing 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 an additional <CRLF>. Implements RFC 821: DATA <CRLF>.

Paramètres
string$msg_dataMessage data to send
Renvoie
bool

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

◆ edebug()

edebug (   $str,
  $level = 0 
)
protected

Output debugging info via a user-selected method.

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

Références ENT_QUOTES.

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

◆ errorHandler()

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

Reports an error number and string.

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

Références SMTP\edebug(), et SMTP\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.

Renvoie
string

Références $data, $info, $message, $n, SMTP\$smtp_conn, $this, SMTP\$Timelimit, SMTP\edebug(), SMTP\getError(), null, et SMTP\setError().

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

◆ getDebugLevel()

getDebugLevel ( )

Get debug output level.

Renvoie
int

Références SMTP\$do_debug.

◆ getDebugOutput()

getDebugOutput ( )

Get debug output method.

Renvoie
string

Références SMTP\$Debugoutput.

◆ getError()

getError ( )

Get the latest error.

Renvoie
array

Références SMTP\$error.

Référencé par SMTP\get_lines().

◆ getLastReply()

getLastReply ( )

Get the last reply from the server.

Renvoie
string

Références SMTP\$last_reply.

Référencé par SMTP\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|string|null
Voir également
recordLastTransactionID()

Références SMTP\$last_smtp_transaction_id.

◆ getServerExt()

getServerExt (   $name)

Get metadata about the SMTP server from its HELO/EHLO response. The method works in three ways, dependent on argument value and current state:

  1. HELO/EHLO has not been sent - returns null and populates $this->error.
  2. HELO has been sent - $name == 'HELO': returns server name $name == 'EHLO': returns boolean false $name == any other string: returns null and populates $this->error
  3. EHLO has been sent - $name == 'HELO'|'EHLO': returns the server name $name == any other string: if extension $name exists, returns True or its options (e.g. AUTH mechanisms supported). Otherwise returns False.
Paramètres
string$nameName of SMTP extension or 'HELO'|'EHLO'
Renvoie
string|bool|null

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

◆ getServerExtList()

getServerExtList ( )

Get SMTP extensions available on the server.

Renvoie
array|null

Références SMTP\$server_caps.

◆ getSMTPConnection()

getSMTPConnection (   $host,
  $port = null,
  $timeout = 30,
  $options = [] 
)
protected

Create connection to the SMTP server.

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

Références $options, $this, SMTP\edebug(), null, et SMTP\setError().

Référencé par SMTP\connect().

◆ getTimeout()

getTimeout ( )

Get SMTP timeout.

Renvoie
int

Références SMTP\$Timeout.

◆ getVerp()

getVerp ( )

Get VERP address generation mode.

Renvoie
bool

Références SMTP\$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
Renvoie
bool

Références SMTP\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
Renvoie
string

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

Référencé par SMTP\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
Renvoie
bool

Références SMTP\sendCommand().

◆ noop()

noop ( )

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

Renvoie
bool

Références SMTP\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.

Paramètres
string$typeHELO or EHLO

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

Référencé par SMTP\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
bool$close_on_errorShould the connection close if an error occurs?
Renvoie
bool

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

Référencé par SMTP\connect().

◆ recipient()

recipient (   $address,
  $dsn = '' 
)

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
string$dsnComma separated list of DSN notifications. NEVER, SUCCESS, FAILURE or DELAY. If you specify NEVER all other notifications are ignored.
Renvoie
bool

Références $value, et SMTP\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|string|null

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

Référencé par SMTP\data().

◆ reset()

reset ( )

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

Renvoie
bool True on success

Références SMTP\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
Renvoie
bool

Références SMTP\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
int | array$expectOne or more expected integer success codes
Renvoie
bool True on success

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

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

◆ sendHello()

sendHello (   $hello,
  $host 
)
protected

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

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

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

Référencé par SMTP\hello().

◆ setDebugLevel()

setDebugLevel (   $level = 0)

Set debug output level.

Paramètres
int$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

Références $method.

◆ 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 SMTP\authenticate(), SMTP\close(), SMTP\connect(), SMTP\errorHandler(), SMTP\get_lines(), SMTP\getServerExt(), SMTP\getSMTPConnection(), SMTP\sendCommand(), et SMTP\turn().

◆ setTimeout()

setTimeout (   $timeout = 0)

Set SMTP timeout.

Paramètres
int$timeoutThe timeout duration in seconds

◆ setVerp()

setVerp (   $enabled = false)

Enable or disable VERP address generation.

Paramètres
bool$enabled

Références $enabled.

◆ startTLS()

startTLS ( )

Initiate a TLS (encrypted) session.

Renvoie
bool

Références $this, et SMTP\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>.

Renvoie
bool

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

◆ verify()

verify (   $name)

Send an SMTP VRFY command.

Paramètres
string$nameThe name to verify
Renvoie
bool

Références SMTP\sendCommand().

Documentation des champs

◆ $Debugoutput

$Debugoutput = 'echo'

Référencé par SMTP\getDebugOutput().

◆ $do_debug

$do_debug = self::DEBUG_OFF

Référencé par SMTP\getDebugLevel().

◆ $do_verp

$do_verp = false

Référencé par SMTP\getVerp().

◆ $error

$error
protected
Valeur initiale :
= [
'error' => ''

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

◆ $helo_rply

$helo_rply
protected

◆ $last_reply

$last_reply = ''
protected

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

◆ $last_smtp_transaction_id

$last_smtp_transaction_id
protected

◆ $server_caps

$server_caps
protected

Référencé par SMTP\getServerExtList().

◆ $smtp_conn

$smtp_conn
protected

Référencé par SMTP\get_lines().

◆ $smtp_transaction_id_patterns

$smtp_transaction_id_patterns
protected
Valeur initiale :
= [
'exim' => '/[\d]{3} OK id=(.*)/'

◆ $Timelimit

$Timelimit = 300

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

◆ $Timeout

$Timeout = 300

Référencé par SMTP\getTimeout().

◆ DEBUG_CLIENT

const DEBUG_CLIENT = 1

◆ DEBUG_CONNECTION

const DEBUG_CONNECTION = 3

◆ DEBUG_LOWLEVEL

const DEBUG_LOWLEVEL = 4

◆ DEBUG_OFF

const DEBUG_OFF = 0

◆ DEBUG_SERVER

const DEBUG_SERVER = 2

◆ DEFAULT_PORT

const DEFAULT_PORT = 25

◆ LE

const LE = "\r\n"

◆ MAX_LINE_LENGTH

const MAX_LINE_LENGTH = 998

◆ MAX_REPLY_LENGTH

const MAX_REPLY_LENGTH = 512

◆ VERSION

const VERSION = '6.6.0'

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