ILIAS
release_5-2 Revision v5.2.25-18-g3f80b828510
|
Public Member Functions | |
connect ($host, $port=null, $timeout=30, $options=array()) | |
Connect to an SMTP server. More... | |
startTLS () | |
Initiate a TLS (encrypted) session. More... | |
authenticate ( $username, $password, $authtype=null, $realm='', $workstation='', $OAuth=null) | |
Perform SMTP authentication. More... | |
connected () | |
Check connection state. More... | |
close () | |
Close the socket and clean up the state of the class. More... | |
data ($msg_data) | |
Send an SMTP DATA command. More... | |
hello ($host='') | |
Send an SMTP HELO or EHLO command. More... | |
mail ($from) | |
Send an SMTP MAIL command. More... | |
quit ($close_on_error=true) | |
Send an SMTP QUIT command. More... | |
recipient ($address) | |
Send an SMTP RCPT command. More... | |
reset () | |
Send an SMTP RSET command. More... | |
sendAndMail ($from) | |
Send an SMTP SAML command. More... | |
verify ($name) | |
Send an SMTP VRFY command. More... | |
noop () | |
Send an SMTP NOOP command. More... | |
turn () | |
Send an SMTP TURN command. More... | |
client_send ($data) | |
Send raw data to the server. More... | |
getError () | |
Get the latest error. More... | |
getServerExtList () | |
Get SMTP extensions available on the server public. More... | |
getServerExt ($name) | |
A multipurpose method The method works in three ways, dependent on argument value and current state. More... | |
getLastReply () | |
Get the last reply from the server. More... | |
setVerp ($enabled=false) | |
Enable or disable VERP address generation. More... | |
getVerp () | |
Get VERP address generation mode. More... | |
setDebugOutput ($method='echo') | |
Set debug output method. More... | |
getDebugOutput () | |
Get debug output method. More... | |
setDebugLevel ($level=0) | |
Set debug output level. More... | |
getDebugLevel () | |
Get debug output level. More... | |
setTimeout ($timeout=0) | |
Set SMTP timeout. More... | |
getTimeout () | |
Get SMTP timeout. More... | |
getLastTransactionID () | |
Will return the ID of the last smtp transaction based on a list of patterns provided in SMTP::$smtp_transaction_id_patterns. More... | |
Data Fields | |
const | VERSION = '5.2.22' |
const | CRLF = "\r\n" |
const | DEFAULT_SMTP_PORT = 25 |
const | MAX_LINE_LENGTH = 998 |
const | DEBUG_OFF = 0 |
Debug level for no output. More... | |
const | DEBUG_CLIENT = 1 |
Debug level to show client -> server messages. More... | |
const | DEBUG_SERVER = 2 |
Debug level to show client -> server and server -> client messages. More... | |
const | DEBUG_CONNECTION = 3 |
Debug level to show connection status, client -> server and server -> client messages. More... | |
const | DEBUG_LOWLEVEL = 4 |
Debug level to show all messages. More... | |
$Version = '5.2.22' | |
$SMTP_PORT = 25 | |
$CRLF = "\r\n" | |
$do_debug = self::DEBUG_OFF | |
$Debugoutput = 'echo' | |
$do_verp = false | |
$Timeout = 300 | |
$Timelimit = 300 | |
Protected Member Functions | |
edebug ($str, $level=0) | |
Output debugging info via a user-selected method. More... | |
hmac ($data, $key) | |
Calculate an MD5 HMAC hash. More... | |
sendHello ($hello, $host) | |
Send an SMTP HELO or EHLO command. More... | |
parseHelloFields ($type) | |
Parse a reply to HELO/EHLO command to discover server extensions. More... | |
sendCommand ($command, $commandstring, $expect) | |
Send a command to an SMTP server and check its return code. More... | |
get_lines () | |
Read the SMTP server's response. More... | |
setError ($message, $detail='', $smtp_code='', $smtp_code_ex='') | |
Set error messages and codes. More... | |
errorHandler ($errno, $errmsg) | |
Reports an error number and string. More... | |
Protected Attributes | |
$smtp_transaction_id_patterns | |
$smtp_conn | |
$error | |
$helo_rply = null | |
$server_caps = null | |
$last_reply = '' | |
Definition at line 27 of file class.smtp.php.
SMTP::authenticate | ( | $username, | |
$password, | |||
$authtype = null , |
|||
$realm = '' , |
|||
$workstation = '' , |
|||
$OAuth = null |
|||
) |
Perform SMTP authentication.
Must be run after hello().
string | $username | The user name |
string | $password | The password |
string | $authtype | The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2) |
string | $realm | The auth realm for NTLM |
string | $workstation | The auth workstation for NTLM |
null | OAuth | $OAuth | An optional OAuth instance ( |
Definition at line 387 of file class.smtp.php.
References array, edebug(), hmac(), sendCommand(), and setError().
SMTP::client_send | ( | $data | ) |
Send raw data to the server.
string | $data | The data to send public |
Definition at line 989 of file class.smtp.php.
References $data, and edebug().
Referenced by data(), and sendCommand().
SMTP::close | ( | ) |
Close the socket and clean up the state of the class.
Don't use this function without first trying to use QUIT.
Definition at line 614 of file class.smtp.php.
References edebug(), and setError().
Referenced by connected(), and quit().
SMTP::connect | ( | $host, | |
$port = null , |
|||
$timeout = 30 , |
|||
$options = array() |
|||
) |
Connect to an SMTP server.
string | $host | SMTP server IP or host name |
integer | $port | The port number to connect to |
integer | $timeout | How long to wait for the connection to open |
array | $options | An array of options for stream_context_create() public |
Definition at line 258 of file class.smtp.php.
References $options, array, connected(), edebug(), get_lines(), and setError().
SMTP::connected | ( | ) |
Check connection state.
public
Definition at line 589 of file class.smtp.php.
References close(), and edebug().
Referenced by connect(), and sendCommand().
SMTP::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>
string | $msg_data | Message data to send public |
Definition at line 639 of file class.smtp.php.
References $result, $Timelimit, array, client_send(), and sendCommand().
|
protected |
Output debugging info via a user-selected method.
string | $str | Debug string to output |
integer | $level | The debug level of this message; see DEBUG_* constants |
Definition at line 213 of file class.smtp.php.
References array, and Monolog\Handler\error_log().
Referenced by authenticate(), client_send(), close(), connect(), connected(), errorHandler(), get_lines(), sendCommand(), and turn().
|
protected |
Reports an error number and string.
integer | $errno | The error number returned by PHP. |
string | $errmsg | The error message returned by PHP. |
Definition at line 1212 of file class.smtp.php.
References edebug(), and setError().
|
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
Definition at line 1075 of file class.smtp.php.
References $data, $info, $Timelimit, edebug(), and time.
Referenced by connect(), and sendCommand().
SMTP::getDebugLevel | ( | ) |
Get debug output level.
Definition at line 1184 of file class.smtp.php.
References $do_debug.
SMTP::getDebugOutput | ( | ) |
Get debug output method.
Definition at line 1166 of file class.smtp.php.
References $Debugoutput.
SMTP::getError | ( | ) |
Get the latest error.
public
Definition at line 1000 of file class.smtp.php.
References $error.
SMTP::getLastReply | ( | ) |
Get the last reply from the server.
public
Definition at line 1061 of file class.smtp.php.
References $last_reply.
Referenced by getLastTransactionID().
SMTP::getLastTransactionID | ( | ) |
Will return the ID of the last smtp transaction based on a list of patterns provided in SMTP::$smtp_transaction_id_patterns.
If no reply has been received yet, it will return null. If no pattern has been matched, it will return false.
Definition at line 1233 of file class.smtp.php.
References getLastReply().
SMTP::getServerExt | ( | $name | ) |
A multipurpose method The method works in three ways, dependent on argument value and current state.
null returned: handshake was not or we don't know about ext (refer to $this->error)
string | $name | Name of SMTP extension or 'HELO'|'EHLO' |
Definition at line 1034 of file class.smtp.php.
References setError().
SMTP::getServerExtList | ( | ) |
Get SMTP extensions available on the server public.
Definition at line 1010 of file class.smtp.php.
References $server_caps.
SMTP::getTimeout | ( | ) |
Get SMTP timeout.
Definition at line 1202 of file class.smtp.php.
References $Timeout.
SMTP::getVerp | ( | ) |
Get VERP address generation mode.
Definition at line 1131 of file class.smtp.php.
References $do_verp.
SMTP::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.
string | $host | The host name or IP to connect to public |
Definition at line 728 of file class.smtp.php.
References sendHello().
|
protected |
Calculate an MD5 HMAC hash.
Works like hash_hmac('md5', $data, $key) in case that function is not available
string | $data | The data to hash |
string | $key | The key to hash with protected |
Definition at line 557 of file class.smtp.php.
References $data.
Referenced by authenticate().
SMTP::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>
string | $from | Source address of this message public |
Definition at line 808 of file class.smtp.php.
References sendCommand().
SMTP::noop | ( | ) |
Send an SMTP NOOP command.
Used to keep keep-alives alive, doesn't actually do anything public
Definition at line 962 of file class.smtp.php.
References sendCommand().
|
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
string | $type | - 'HELO' or 'EHLO' |
Definition at line 761 of file class.smtp.php.
Referenced by sendHello().
SMTP::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>
boolean | $close_on_error | Should the connection close if an error occurs? public |
Definition at line 826 of file class.smtp.php.
References $error, close(), and sendCommand().
SMTP::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>
string | $address | The address the message is being sent to public |
Definition at line 846 of file class.smtp.php.
References array, and sendCommand().
SMTP::reset | ( | ) |
Send an SMTP RSET command.
Abort any transaction that is currently in progress. Implements rfc 821: RSET <CRLF> public
Definition at line 862 of file class.smtp.php.
References sendCommand().
SMTP::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>
string | $from | The address the message is from public |
Definition at line 940 of file class.smtp.php.
References sendCommand().
|
protected |
Send a command to an SMTP server and check its return code.
string | $command | The command name - not sent to the server |
string | $commandstring | The actual command to send |
integer | array | $expect | One or more expected integer success codes protected |
Definition at line 875 of file class.smtp.php.
References $code, array, client_send(), connected(), edebug(), get_lines(), and setError().
Referenced by authenticate(), data(), mail(), noop(), quit(), recipient(), reset(), sendAndMail(), sendHello(), startTLS(), and verify().
|
protected |
Send an SMTP HELO or EHLO command.
Low-level implementation used by hello()
string | $hello | The HELO string |
string | $host | The hostname to say we are protected |
Definition at line 743 of file class.smtp.php.
References $last_reply, parseHelloFields(), and sendCommand().
Referenced by hello().
SMTP::setDebugLevel | ( | $level = 0 | ) |
SMTP::setDebugOutput | ( | $method = 'echo' | ) |
Set debug output method.
string | callable | $method | The name of the mechanism to use for debugging output, or a callable to handle it. |
Definition at line 1157 of file class.smtp.php.
|
protected |
Set error messages and codes.
string | $message | The error message |
string | $detail | Further detail on the error |
string | $smtp_code | An associated SMTP error code |
string | $smtp_code_ex | Extended SMTP code |
Definition at line 1143 of file class.smtp.php.
References array.
Referenced by authenticate(), close(), connect(), errorHandler(), getServerExt(), sendCommand(), and turn().
SMTP::setTimeout | ( | $timeout = 0 | ) |
SMTP::setVerp | ( | $enabled = false | ) |
Enable or disable VERP address generation.
boolean | $enabled |
Definition at line 1122 of file class.smtp.php.
SMTP::startTLS | ( | ) |
Initiate a TLS (encrypted) session.
public
Definition at line 348 of file class.smtp.php.
References defined, and sendCommand().
SMTP::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
Definition at line 976 of file class.smtp.php.
References edebug(), and setError().
SMTP::verify | ( | $name | ) |
Send an SMTP VRFY command.
string | $name | The name to verify public |
Definition at line 951 of file class.smtp.php.
References array, and sendCommand().
SMTP::$CRLF = "\r\n" |
Definition at line 100 of file class.smtp.php.
SMTP::$Debugoutput = 'echo' |
Definition at line 127 of file class.smtp.php.
Referenced by getDebugOutput().
SMTP::$do_debug = self::DEBUG_OFF |
Definition at line 112 of file class.smtp.php.
Referenced by getDebugLevel().
SMTP::$do_verp = false |
Definition at line 135 of file class.smtp.php.
Referenced by getVerp().
|
protected |
Definition at line 174 of file class.smtp.php.
Referenced by getError(), and quit().
|
protected |
Definition at line 186 of file class.smtp.php.
|
protected |
Definition at line 203 of file class.smtp.php.
Referenced by getLastReply(), and sendHello().
|
protected |
Definition at line 197 of file class.smtp.php.
Referenced by getServerExtList().
|
protected |
Definition at line 168 of file class.smtp.php.
SMTP::$SMTP_PORT = 25 |
Definition at line 92 of file class.smtp.php.
|
protected |
Definition at line 158 of file class.smtp.php.
SMTP::$Timelimit = 300 |
Definition at line 151 of file class.smtp.php.
Referenced by data(), and get_lines().
SMTP::$Timeout = 300 |
Definition at line 144 of file class.smtp.php.
Referenced by getTimeout().
SMTP::$Version = '5.2.22' |
Definition at line 84 of file class.smtp.php.
const SMTP::CRLF = "\r\n" |
Definition at line 39 of file class.smtp.php.
const SMTP::DEBUG_CLIENT = 1 |
Debug level to show client -> server messages.
Definition at line 61 of file class.smtp.php.
const SMTP::DEBUG_CONNECTION = 3 |
Debug level to show connection status, client -> server and server -> client messages.
Definition at line 71 of file class.smtp.php.
const SMTP::DEBUG_LOWLEVEL = 4 |
Debug level to show all messages.
Definition at line 76 of file class.smtp.php.
const SMTP::DEBUG_OFF = 0 |
Debug level for no output.
Definition at line 56 of file class.smtp.php.
const SMTP::DEBUG_SERVER = 2 |
Debug level to show client -> server and server -> client messages.
Definition at line 66 of file class.smtp.php.
const SMTP::DEFAULT_SMTP_PORT = 25 |
Definition at line 45 of file class.smtp.php.
const SMTP::MAX_LINE_LENGTH = 998 |
Definition at line 51 of file class.smtp.php.
const SMTP::VERSION = '5.2.22' |
Definition at line 33 of file class.smtp.php.