Свойство | Тип | Описание | |
---|---|---|---|
$Debugoutput | string | callable | 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:
$smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
|
|
$Timelimit | integer | Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 | |
$Timeout | integer | 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. | |
$do_debug | integer | 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 | |
$do_verp | boolean | Whether to use VERP. |
Свойство | Тип | Описание | |
---|---|---|---|
$error | array | Error information, if any, for the last SMTP command. | |
$helo_rply | string | null | If null, no HELO string has yet been received. | |
$last_reply | string | The most recent reply received from the server. | |
$server_caps | array | null | Indexes of the array are extension names. Value at index 'HELO' or 'EHLO' (according to command that was sent) represents the server name. In case of HELO it is the only element of the array. Other values can be boolean TRUE or an array containing extension options. If null, no HELO/EHLO string has yet been received. | |
$smtp_conn | resource | The socket for the server connection. |
Метод | Описание | |
---|---|---|
authenticate ( string $username, string $password, string $authtype = null, |
Perform SMTP authentication. | |
client_send ( string $data ) : integer | boolean | Send raw data to the server. | |
close ( ) : void | Close the socket and clean up the state of the class. | |
connect ( string $host, integer $port = null, integer $timeout = 30, array $options = [] ) : boolean | Connect to an SMTP server. | |
connected ( ) : boolean | Check connection state. | |
data ( string $msg_data ) : boolean | Send an SMTP DATA command. | |
getDebugLevel ( ) : integer | Get debug output level. | |
getDebugOutput ( ) : string | Get debug output method. | |
getError ( ) : array | Get the latest error. | |
getLastReply ( ) : string | Get the last reply from the server. | |
getServerExt ( string $name ) : mixed | 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 | |
getServerExtList ( ) : array | null | Get SMTP extensions available on the server | |
getTimeout ( ) : integer | Get SMTP timeout. | |
getVerp ( ) : boolean | Get VERP address generation mode. | |
hello ( string $host = '' ) : boolean | Send an SMTP HELO or EHLO command. | |
mail ( string $from ) : boolean | Send an SMTP MAIL command. | |
noop ( ) : boolean | Send an SMTP NOOP command. | |
quit ( boolean $close_on_error = true ) : boolean | Send an SMTP QUIT command. | |
recipient ( string $address ) : boolean | Send an SMTP RCPT command. | |
reset ( ) : boolean | Send an SMTP RSET command. | |
sendAndMail ( string $from ) : boolean | Send an SMTP SAML command. | |
setDebugLevel ( integer $level ) | Set debug output level. | |
setDebugOutput ( string | callable $method = 'echo' ) | Set debug output method. | |
setTimeout ( integer $timeout ) | Set SMTP timeout. | |
setVerp ( boolean $enabled = false ) | Enable or disable VERP address generation. | |
startTLS ( ) : boolean | Initiate a TLS (encrypted) session. | |
turn ( ) : boolean | Send an SMTP TURN command. | |
verify ( string $name ) : boolean | Send an SMTP VRFY command. |
Метод | Описание | |
---|---|---|
edebug ( string $str, integer $level ) : void | Output debugging info via a user-selected method. | |
get_lines ( ) : string | Read the SMTP server's response. | |
hmac ( string $data, string $key ) : string | Calculate an MD5 HMAC hash. | |
parseHelloFields ( string $type ) | Parse a reply to HELO/EHLO command to discover server extensions. | |
sendCommand ( string $command, string $commandstring, integer | array $expect ) : boolean | Send a command to an SMTP server and check its return code. | |
sendHello ( string $hello, string $host ) : boolean | Send an SMTP HELO or EHLO command. | |
setError ( string $message, string $detail = '', string $smtp_code = '', string $smtp_code_ex = '' ) | Set error messages and codes. |
public authenticate ( string $username, string $password, string $authtype = null, |
||
$username | string | The user name |
$password | string | The password |
$authtype | string | The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2) |
$OAuth | An optional OAuth instance for XOAUTH2 authentication | |
Результат | boolean | True if successfully authenticated. |
public connect ( string $host, integer $port = null, integer $timeout = 30, array $options = [] ) : boolean | ||
$host | string | SMTP server IP or host name |
$port | integer | The port number to connect to |
$timeout | integer | How long to wait for the connection to open |
$options | array | An array of options for stream_context_create() |
Результат | boolean |
public getDebugLevel ( ) : integer | ||
Результат | integer |
public getDebugOutput ( ) : string | ||
Результат | string |
public getLastReply ( ) : string | ||
Результат | string |
public getServerExt ( string $name ) : mixed | ||
$name | string | Name of SMTP extension or 'HELO'|'EHLO' |
Результат | mixed |
public getServerExtList ( ) : array | null | ||
Результат | array | null |
protected parseHelloFields ( string $type ) | ||
$type | string | - 'HELO' or 'EHLO' |
public sendAndMail ( string $from ) : boolean | ||
$from | string | The address the message is from |
Результат | boolean |
protected sendCommand ( string $command, string $commandstring, integer | array $expect ) : boolean | ||
$command | string | The command name - not sent to the server |
$commandstring | string | The actual command to send |
$expect | integer | array | One or more expected integer success codes |
Результат | boolean | True on success. |
public setDebugLevel ( integer $level ) | ||
$level | integer |
public setDebugOutput ( string | callable $method = 'echo' ) | ||
$method | string | callable | The name of the mechanism to use for debugging output, or a callable to handle it. |
public setTimeout ( integer $timeout ) | ||
$timeout | integer |
$smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
public int $Timelimit | ||
Результат | integer |
public int $Timeout | ||
Результат | integer |
public int $do_debug | ||
Результат | integer |
protected array $error | ||
Результат | array |
protected string $last_reply | ||
Результат | string |