Edit File by line
/home/barbar84/public_h.../wp-inclu.../PHPMaile...
File: SMTP.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* PHPMailer RFC821 SMTP email transport class.
[3] Fix | Delete
* PHP Version 5.5.
[4] Fix | Delete
*
[5] Fix | Delete
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
[6] Fix | Delete
*
[7] Fix | Delete
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
[8] Fix | Delete
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
[9] Fix | Delete
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
[10] Fix | Delete
* @author Brent R. Matzelle (original founder)
[11] Fix | Delete
* @copyright 2012 - 2020 Marcus Bointon
[12] Fix | Delete
* @copyright 2010 - 2012 Jim Jagielski
[13] Fix | Delete
* @copyright 2004 - 2009 Andy Prevost
[14] Fix | Delete
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
[15] Fix | Delete
* @note This program is distributed in the hope that it will be useful - WITHOUT
[16] Fix | Delete
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
[17] Fix | Delete
* FITNESS FOR A PARTICULAR PURPOSE.
[18] Fix | Delete
*/
[19] Fix | Delete
[20] Fix | Delete
namespace PHPMailer\PHPMailer;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* PHPMailer RFC821 SMTP email transport class.
[24] Fix | Delete
* Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
[25] Fix | Delete
*
[26] Fix | Delete
* @author Chris Ryan
[27] Fix | Delete
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
[28] Fix | Delete
*/
[29] Fix | Delete
class SMTP
[30] Fix | Delete
{
[31] Fix | Delete
/**
[32] Fix | Delete
* The PHPMailer SMTP version number.
[33] Fix | Delete
*
[34] Fix | Delete
* @var string
[35] Fix | Delete
*/
[36] Fix | Delete
const VERSION = '6.5.0';
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* SMTP line break constant.
[40] Fix | Delete
*
[41] Fix | Delete
* @var string
[42] Fix | Delete
*/
[43] Fix | Delete
const LE = "\r\n";
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* The SMTP port to use if one is not specified.
[47] Fix | Delete
*
[48] Fix | Delete
* @var int
[49] Fix | Delete
*/
[50] Fix | Delete
const DEFAULT_PORT = 25;
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* The maximum line length allowed by RFC 5321 section 4.5.3.1.6,
[54] Fix | Delete
* *excluding* a trailing CRLF break.
[55] Fix | Delete
*
[56] Fix | Delete
* @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.6
[57] Fix | Delete
*
[58] Fix | Delete
* @var int
[59] Fix | Delete
*/
[60] Fix | Delete
const MAX_LINE_LENGTH = 998;
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* The maximum line length allowed for replies in RFC 5321 section 4.5.3.1.5,
[64] Fix | Delete
* *including* a trailing CRLF line break.
[65] Fix | Delete
*
[66] Fix | Delete
* @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.5
[67] Fix | Delete
*
[68] Fix | Delete
* @var int
[69] Fix | Delete
*/
[70] Fix | Delete
const MAX_REPLY_LENGTH = 512;
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Debug level for no output.
[74] Fix | Delete
*
[75] Fix | Delete
* @var int
[76] Fix | Delete
*/
[77] Fix | Delete
const DEBUG_OFF = 0;
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Debug level to show client -> server messages.
[81] Fix | Delete
*
[82] Fix | Delete
* @var int
[83] Fix | Delete
*/
[84] Fix | Delete
const DEBUG_CLIENT = 1;
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Debug level to show client -> server and server -> client messages.
[88] Fix | Delete
*
[89] Fix | Delete
* @var int
[90] Fix | Delete
*/
[91] Fix | Delete
const DEBUG_SERVER = 2;
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Debug level to show connection status, client -> server and server -> client messages.
[95] Fix | Delete
*
[96] Fix | Delete
* @var int
[97] Fix | Delete
*/
[98] Fix | Delete
const DEBUG_CONNECTION = 3;
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Debug level to show all messages.
[102] Fix | Delete
*
[103] Fix | Delete
* @var int
[104] Fix | Delete
*/
[105] Fix | Delete
const DEBUG_LOWLEVEL = 4;
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Debug output level.
[109] Fix | Delete
* Options:
[110] Fix | Delete
* * self::DEBUG_OFF (`0`) No debug output, default
[111] Fix | Delete
* * self::DEBUG_CLIENT (`1`) Client commands
[112] Fix | Delete
* * self::DEBUG_SERVER (`2`) Client commands and server responses
[113] Fix | Delete
* * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
[114] Fix | Delete
* * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages.
[115] Fix | Delete
*
[116] Fix | Delete
* @var int
[117] Fix | Delete
*/
[118] Fix | Delete
public $do_debug = self::DEBUG_OFF;
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* How to handle debug output.
[122] Fix | Delete
* Options:
[123] Fix | Delete
* * `echo` Output plain-text as-is, appropriate for CLI
[124] Fix | Delete
* * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
[125] Fix | Delete
* * `error_log` Output to error log as configured in php.ini
[126] Fix | Delete
* Alternatively, you can provide a callable expecting two params: a message string and the debug level:
[127] Fix | Delete
*
[128] Fix | Delete
* ```php
[129] Fix | Delete
* $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
[130] Fix | Delete
* ```
[131] Fix | Delete
*
[132] Fix | Delete
* Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only `debug`
[133] Fix | Delete
* level output is used:
[134] Fix | Delete
*
[135] Fix | Delete
* ```php
[136] Fix | Delete
* $mail->Debugoutput = new myPsr3Logger;
[137] Fix | Delete
* ```
[138] Fix | Delete
*
[139] Fix | Delete
* @var string|callable|\Psr\Log\LoggerInterface
[140] Fix | Delete
*/
[141] Fix | Delete
public $Debugoutput = 'echo';
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Whether to use VERP.
[145] Fix | Delete
*
[146] Fix | Delete
* @see http://en.wikipedia.org/wiki/Variable_envelope_return_path
[147] Fix | Delete
* @see http://www.postfix.org/VERP_README.html Info on VERP
[148] Fix | Delete
*
[149] Fix | Delete
* @var bool
[150] Fix | Delete
*/
[151] Fix | Delete
public $do_verp = false;
[152] Fix | Delete
[153] Fix | Delete
/**
[154] Fix | Delete
* The timeout value for connection, in seconds.
[155] Fix | Delete
* Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
[156] Fix | Delete
* This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure.
[157] Fix | Delete
*
[158] Fix | Delete
* @see http://tools.ietf.org/html/rfc2821#section-4.5.3.2
[159] Fix | Delete
*
[160] Fix | Delete
* @var int
[161] Fix | Delete
*/
[162] Fix | Delete
public $Timeout = 300;
[163] Fix | Delete
[164] Fix | Delete
/**
[165] Fix | Delete
* How long to wait for commands to complete, in seconds.
[166] Fix | Delete
* Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
[167] Fix | Delete
*
[168] Fix | Delete
* @var int
[169] Fix | Delete
*/
[170] Fix | Delete
public $Timelimit = 300;
[171] Fix | Delete
[172] Fix | Delete
/**
[173] Fix | Delete
* Patterns to extract an SMTP transaction id from reply to a DATA command.
[174] Fix | Delete
* The first capture group in each regex will be used as the ID.
[175] Fix | Delete
* MS ESMTP returns the message ID, which may not be correct for internal tracking.
[176] Fix | Delete
*
[177] Fix | Delete
* @var string[]
[178] Fix | Delete
*/
[179] Fix | Delete
protected $smtp_transaction_id_patterns = [
[180] Fix | Delete
'exim' => '/[\d]{3} OK id=(.*)/',
[181] Fix | Delete
'sendmail' => '/[\d]{3} 2.0.0 (.*) Message/',
[182] Fix | Delete
'postfix' => '/[\d]{3} 2.0.0 Ok: queued as (.*)/',
[183] Fix | Delete
'Microsoft_ESMTP' => '/[0-9]{3} 2.[\d].0 (.*)@(?:.*) Queued mail for delivery/',
[184] Fix | Delete
'Amazon_SES' => '/[\d]{3} Ok (.*)/',
[185] Fix | Delete
'SendGrid' => '/[\d]{3} Ok: queued as (.*)/',
[186] Fix | Delete
'CampaignMonitor' => '/[\d]{3} 2.0.0 OK:([a-zA-Z\d]{48})/',
[187] Fix | Delete
'Haraka' => '/[\d]{3} Message Queued \((.*)\)/',
[188] Fix | Delete
];
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* The last transaction ID issued in response to a DATA command,
[192] Fix | Delete
* if one was detected.
[193] Fix | Delete
*
[194] Fix | Delete
* @var string|bool|null
[195] Fix | Delete
*/
[196] Fix | Delete
protected $last_smtp_transaction_id;
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* The socket for the server connection.
[200] Fix | Delete
*
[201] Fix | Delete
* @var ?resource
[202] Fix | Delete
*/
[203] Fix | Delete
protected $smtp_conn;
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* Error information, if any, for the last SMTP command.
[207] Fix | Delete
*
[208] Fix | Delete
* @var array
[209] Fix | Delete
*/
[210] Fix | Delete
protected $error = [
[211] Fix | Delete
'error' => '',
[212] Fix | Delete
'detail' => '',
[213] Fix | Delete
'smtp_code' => '',
[214] Fix | Delete
'smtp_code_ex' => '',
[215] Fix | Delete
];
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* The reply the server sent to us for HELO.
[219] Fix | Delete
* If null, no HELO string has yet been received.
[220] Fix | Delete
*
[221] Fix | Delete
* @var string|null
[222] Fix | Delete
*/
[223] Fix | Delete
protected $helo_rply;
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
* The set of SMTP extensions sent in reply to EHLO command.
[227] Fix | Delete
* Indexes of the array are extension names.
[228] Fix | Delete
* Value at index 'HELO' or 'EHLO' (according to command that was sent)
[229] Fix | Delete
* represents the server name. In case of HELO it is the only element of the array.
[230] Fix | Delete
* Other values can be boolean TRUE or an array containing extension options.
[231] Fix | Delete
* If null, no HELO/EHLO string has yet been received.
[232] Fix | Delete
*
[233] Fix | Delete
* @var array|null
[234] Fix | Delete
*/
[235] Fix | Delete
protected $server_caps;
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* The most recent reply received from the server.
[239] Fix | Delete
*
[240] Fix | Delete
* @var string
[241] Fix | Delete
*/
[242] Fix | Delete
protected $last_reply = '';
[243] Fix | Delete
[244] Fix | Delete
/**
[245] Fix | Delete
* Output debugging info via a user-selected method.
[246] Fix | Delete
*
[247] Fix | Delete
* @param string $str Debug string to output
[248] Fix | Delete
* @param int $level The debug level of this message; see DEBUG_* constants
[249] Fix | Delete
*
[250] Fix | Delete
* @see SMTP::$Debugoutput
[251] Fix | Delete
* @see SMTP::$do_debug
[252] Fix | Delete
*/
[253] Fix | Delete
protected function edebug($str, $level = 0)
[254] Fix | Delete
{
[255] Fix | Delete
if ($level > $this->do_debug) {
[256] Fix | Delete
return;
[257] Fix | Delete
}
[258] Fix | Delete
//Is this a PSR-3 logger?
[259] Fix | Delete
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
[260] Fix | Delete
$this->Debugoutput->debug($str);
[261] Fix | Delete
[262] Fix | Delete
return;
[263] Fix | Delete
}
[264] Fix | Delete
//Avoid clash with built-in function names
[265] Fix | Delete
if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) {
[266] Fix | Delete
call_user_func($this->Debugoutput, $str, $level);
[267] Fix | Delete
[268] Fix | Delete
return;
[269] Fix | Delete
}
[270] Fix | Delete
switch ($this->Debugoutput) {
[271] Fix | Delete
case 'error_log':
[272] Fix | Delete
//Don't output, just log
[273] Fix | Delete
error_log($str);
[274] Fix | Delete
break;
[275] Fix | Delete
case 'html':
[276] Fix | Delete
//Cleans up output a bit for a better looking, HTML-safe output
[277] Fix | Delete
echo gmdate('Y-m-d H:i:s'), ' ', htmlentities(
[278] Fix | Delete
preg_replace('/[\r\n]+/', '', $str),
[279] Fix | Delete
ENT_QUOTES,
[280] Fix | Delete
'UTF-8'
[281] Fix | Delete
), "<br>\n";
[282] Fix | Delete
break;
[283] Fix | Delete
case 'echo':
[284] Fix | Delete
default:
[285] Fix | Delete
//Normalize line breaks
[286] Fix | Delete
$str = preg_replace('/\r\n|\r/m', "\n", $str);
[287] Fix | Delete
echo gmdate('Y-m-d H:i:s'),
[288] Fix | Delete
"\t",
[289] Fix | Delete
//Trim trailing space
[290] Fix | Delete
trim(
[291] Fix | Delete
//Indent for readability, except for trailing break
[292] Fix | Delete
str_replace(
[293] Fix | Delete
"\n",
[294] Fix | Delete
"\n \t ",
[295] Fix | Delete
trim($str)
[296] Fix | Delete
)
[297] Fix | Delete
),
[298] Fix | Delete
"\n";
[299] Fix | Delete
}
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
/**
[303] Fix | Delete
* Connect to an SMTP server.
[304] Fix | Delete
*
[305] Fix | Delete
* @param string $host SMTP server IP or host name
[306] Fix | Delete
* @param int $port The port number to connect to
[307] Fix | Delete
* @param int $timeout How long to wait for the connection to open
[308] Fix | Delete
* @param array $options An array of options for stream_context_create()
[309] Fix | Delete
*
[310] Fix | Delete
* @return bool
[311] Fix | Delete
*/
[312] Fix | Delete
public function connect($host, $port = null, $timeout = 30, $options = [])
[313] Fix | Delete
{
[314] Fix | Delete
//Clear errors to avoid confusion
[315] Fix | Delete
$this->setError('');
[316] Fix | Delete
//Make sure we are __not__ connected
[317] Fix | Delete
if ($this->connected()) {
[318] Fix | Delete
//Already connected, generate error
[319] Fix | Delete
$this->setError('Already connected to a server');
[320] Fix | Delete
[321] Fix | Delete
return false;
[322] Fix | Delete
}
[323] Fix | Delete
if (empty($port)) {
[324] Fix | Delete
$port = self::DEFAULT_PORT;
[325] Fix | Delete
}
[326] Fix | Delete
//Connect to the SMTP server
[327] Fix | Delete
$this->edebug(
[328] Fix | Delete
"Connection: opening to $host:$port, timeout=$timeout, options=" .
[329] Fix | Delete
(count($options) > 0 ? var_export($options, true) : 'array()'),
[330] Fix | Delete
self::DEBUG_CONNECTION
[331] Fix | Delete
);
[332] Fix | Delete
[333] Fix | Delete
$this->smtp_conn = $this->getSMTPConnection($host, $port, $timeout, $options);
[334] Fix | Delete
[335] Fix | Delete
if ($this->smtp_conn === false) {
[336] Fix | Delete
//Error info already set inside `getSMTPConnection()`
[337] Fix | Delete
return false;
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
$this->edebug('Connection: opened', self::DEBUG_CONNECTION);
[341] Fix | Delete
[342] Fix | Delete
//Get any announcement
[343] Fix | Delete
$this->last_reply = $this->get_lines();
[344] Fix | Delete
$this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
[345] Fix | Delete
$responseCode = (int)substr($this->last_reply, 0, 3);
[346] Fix | Delete
if ($responseCode === 220) {
[347] Fix | Delete
return true;
[348] Fix | Delete
}
[349] Fix | Delete
//Anything other than a 220 response means something went wrong
[350] Fix | Delete
//RFC 5321 says the server will wait for us to send a QUIT in response to a 554 error
[351] Fix | Delete
//https://tools.ietf.org/html/rfc5321#section-3.1
[352] Fix | Delete
if ($responseCode === 554) {
[353] Fix | Delete
$this->quit();
[354] Fix | Delete
}
[355] Fix | Delete
//This will handle 421 responses which may not wait for a QUIT (e.g. if the server is being shut down)
[356] Fix | Delete
$this->edebug('Connection: closing due to error', self::DEBUG_CONNECTION);
[357] Fix | Delete
$this->close();
[358] Fix | Delete
return false;
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
/**
[362] Fix | Delete
* Create connection to the SMTP server.
[363] Fix | Delete
*
[364] Fix | Delete
* @param string $host SMTP server IP or host name
[365] Fix | Delete
* @param int $port The port number to connect to
[366] Fix | Delete
* @param int $timeout How long to wait for the connection to open
[367] Fix | Delete
* @param array $options An array of options for stream_context_create()
[368] Fix | Delete
*
[369] Fix | Delete
* @return false|resource
[370] Fix | Delete
*/
[371] Fix | Delete
protected function getSMTPConnection($host, $port = null, $timeout = 30, $options = [])
[372] Fix | Delete
{
[373] Fix | Delete
static $streamok;
[374] Fix | Delete
//This is enabled by default since 5.0.0 but some providers disable it
[375] Fix | Delete
//Check this once and cache the result
[376] Fix | Delete
if (null === $streamok) {
[377] Fix | Delete
$streamok = function_exists('stream_socket_client');
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
$errno = 0;
[381] Fix | Delete
$errstr = '';
[382] Fix | Delete
if ($streamok) {
[383] Fix | Delete
$socket_context = stream_context_create($options);
[384] Fix | Delete
set_error_handler([$this, 'errorHandler']);
[385] Fix | Delete
$connection = stream_socket_client(
[386] Fix | Delete
$host . ':' . $port,
[387] Fix | Delete
$errno,
[388] Fix | Delete
$errstr,
[389] Fix | Delete
$timeout,
[390] Fix | Delete
STREAM_CLIENT_CONNECT,
[391] Fix | Delete
$socket_context
[392] Fix | Delete
);
[393] Fix | Delete
restore_error_handler();
[394] Fix | Delete
} else {
[395] Fix | Delete
//Fall back to fsockopen which should work in more places, but is missing some features
[396] Fix | Delete
$this->edebug(
[397] Fix | Delete
'Connection: stream_socket_client not available, falling back to fsockopen',
[398] Fix | Delete
self::DEBUG_CONNECTION
[399] Fix | Delete
);
[400] Fix | Delete
set_error_handler([$this, 'errorHandler']);
[401] Fix | Delete
$connection = fsockopen(
[402] Fix | Delete
$host,
[403] Fix | Delete
$port,
[404] Fix | Delete
$errno,
[405] Fix | Delete
$errstr,
[406] Fix | Delete
$timeout
[407] Fix | Delete
);
[408] Fix | Delete
restore_error_handler();
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
//Verify we connected properly
[412] Fix | Delete
if (!is_resource($connection)) {
[413] Fix | Delete
$this->setError(
[414] Fix | Delete
'Failed to connect to server',
[415] Fix | Delete
'',
[416] Fix | Delete
(string) $errno,
[417] Fix | Delete
$errstr
[418] Fix | Delete
);
[419] Fix | Delete
$this->edebug(
[420] Fix | Delete
'SMTP ERROR: ' . $this->error['error']
[421] Fix | Delete
. ": $errstr ($errno)",
[422] Fix | Delete
self::DEBUG_CLIENT
[423] Fix | Delete
);
[424] Fix | Delete
[425] Fix | Delete
return false;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
//SMTP server can take longer to respond, give longer timeout for first read
[429] Fix | Delete
//Windows does not have support for this timeout function
[430] Fix | Delete
if (strpos(PHP_OS, 'WIN') !== 0) {
[431] Fix | Delete
$max = (int)ini_get('max_execution_time');
[432] Fix | Delete
//Don't bother if unlimited, or if set_time_limit is disabled
[433] Fix | Delete
if (0 !== $max && $timeout > $max && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
[434] Fix | Delete
@set_time_limit($timeout);
[435] Fix | Delete
}
[436] Fix | Delete
stream_set_timeout($connection, $timeout, 0);
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
return $connection;
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
/**
[443] Fix | Delete
* Initiate a TLS (encrypted) session.
[444] Fix | Delete
*
[445] Fix | Delete
* @return bool
[446] Fix | Delete
*/
[447] Fix | Delete
public function startTLS()
[448] Fix | Delete
{
[449] Fix | Delete
if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
[450] Fix | Delete
return false;
[451] Fix | Delete
}
[452] Fix | Delete
[453] Fix | Delete
//Allow the best TLS version(s) we can
[454] Fix | Delete
$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
[455] Fix | Delete
[456] Fix | Delete
//PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
[457] Fix | Delete
//so add them back in manually if we can
[458] Fix | Delete
if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
[459] Fix | Delete
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
[460] Fix | Delete
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
//Begin encrypted connection
[464] Fix | Delete
set_error_handler([$this, 'errorHandler']);
[465] Fix | Delete
$crypto_ok = stream_socket_enable_crypto(
[466] Fix | Delete
$this->smtp_conn,
[467] Fix | Delete
true,
[468] Fix | Delete
$crypto_method
[469] Fix | Delete
);
[470] Fix | Delete
restore_error_handler();
[471] Fix | Delete
[472] Fix | Delete
return (bool) $crypto_ok;
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* Perform SMTP authentication.
[477] Fix | Delete
* Must be run after hello().
[478] Fix | Delete
*
[479] Fix | Delete
* @see hello()
[480] Fix | Delete
*
[481] Fix | Delete
* @param string $username The user name
[482] Fix | Delete
* @param string $password The password
[483] Fix | Delete
* @param string $authtype The auth type (CRAM-MD5, PLAIN, LOGIN, XOAUTH2)
[484] Fix | Delete
* @param OAuth $OAuth An optional OAuth instance for XOAUTH2 authentication
[485] Fix | Delete
*
[486] Fix | Delete
* @return bool True if successfully authenticated
[487] Fix | Delete
*/
[488] Fix | Delete
public function authenticate(
[489] Fix | Delete
$username,
[490] Fix | Delete
$password,
[491] Fix | Delete
$authtype = null,
[492] Fix | Delete
$OAuth = null
[493] Fix | Delete
) {
[494] Fix | Delete
if (!$this->server_caps) {
[495] Fix | Delete
$this->setError('Authentication is not allowed before HELO/EHLO');
[496] Fix | Delete
[497] Fix | Delete
return false;
[498] Fix | Delete
}
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function