Zeile 128 | Zeile 128 |
---|
* @var boolean */ public $keep_alive = false;
|
* @var boolean */ public $keep_alive = false;
|
| /** * Whether to use TLS encryption. * * @var boolean */ public $use_tls = false;
|
function __construct() {
| function __construct() {
|
Zeile 138 | Zeile 145 |
---|
{ case MYBB_SSL: $protocol = 'ssl://';
|
{ case MYBB_SSL: $protocol = 'ssl://';
|
break;
| break;
|
case MYBB_TLS:
|
case MYBB_TLS:
|
$protocol = 'tls://';
| $this->use_tls = true;
|
break; }
if(empty($mybb->settings['smtp_host'])) { $this->host = @ini_get('SMTP');
|
break; }
if(empty($mybb->settings['smtp_host'])) { $this->host = @ini_get('SMTP');
|
} else {
| } else {
|
$this->host = $mybb->settings['smtp_host']; }
|
$this->host = $mybb->settings['smtp_host']; }
|
$this->helo = $this->host;
| $local = array('127.0.0.1', '::1', 'localhost'); if(!in_array($this->host, $local)) { if(function_exists('gethostname') && gethostname() !== false) { $this->helo = gethostname(); } elseif(function_exists('php_uname')) { $helo = php_uname('n'); if(!empty($helo)) { $this->helo = $helo; } } elseif(!empty($_SERVER['SERVER_NAME'])) { $this->helo = $_SERVER['SERVER_NAME']; } }
|
$this->host = $protocol . $this->host;
| $this->host = $protocol . $this->host;
|
Zeile 185 | Zeile 211 |
---|
if(!$this->connected()) {
|
if(!$this->connected()) {
|
$this->connect();
| if(!$this->connect()) { $this->close(); }
|
} if($this->connected())
|
} if($this->connected())
|
{
| {
|
if(!$this->send_data('MAIL FROM:<'.$this->from.'>', '250')) { $this->fatal_error("The mail server does not understand the MAIL FROM command. Reason: ".$this->get_error());
| if(!$this->send_data('MAIL FROM:<'.$this->from.'>', '250')) { $this->fatal_error("The mail server does not understand the MAIL FROM command. Reason: ".$this->get_error());
|
Zeile 226 | Zeile 255 |
---|
// Queue the actual message $this->message = str_replace("\n.", "\n..", $this->message); $this->send_data($this->message);
|
// Queue the actual message $this->message = str_replace("\n.", "\n..", $this->message); $this->send_data($this->message);
|
} else {
| } else {
|
$this->fatal_error("The mail server did not understand the DATA command"); return false; }
| $this->fatal_error("The mail server did not understand the DATA command"); return false; }
|
Zeile 274 | Zeile 303 |
---|
return false; }
|
return false; }
|
if(!empty($this->username) && !empty($this->password))
| if($this->use_tls || (!empty($this->username) && !empty($this->password))) { $helo = 'EHLO'; } else { $helo = 'HELO'; }
$data = $this->send_data("{$helo} {$this->helo}", '250'); if(!$data) { $this->fatal_error("The server did not understand the {$helo} command"); return false; }
if($this->use_tls && preg_match("#250( |-)STARTTLS#mi", $data))
|
{
|
{
|
$data = $this->send_data('EHLO ' . $this->helo, '250');
| if(!$this->send_data('STARTTLS', '220')) { $this->fatal_error("The server did not understand the STARTTLS command. Reason: ".$this->get_error()); return false; } if(!@stream_socket_enable_crypto($this->connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { $this->fatal_error("Failed to start TLS encryption"); return false; } // Resend EHLO to get updated service list $data = $this->send_data("{$helo} {$this->helo}", '250');
|
if(!$data) { $this->fatal_error("The server did not understand the EHLO command");
|
if(!$data) { $this->fatal_error("The server did not understand the EHLO command");
|
return false; } preg_match("#250-AUTH( |=)(.+)$#mi", $data, $matches); if(!$this->auth($matches[2])) { $this->fatal_error("MyBB was unable to authenticate you against the SMTP server");
| |
return false; } }
|
return false; } }
|
else
| if(!empty($this->username) && !empty($this->password))
|
{
|
{
|
if(!$this->send_data('HELO ' . $this->helo, '250'))
| preg_match("#250( |-)AUTH( |=)(.+)$#mi", $data, $matches); if(!$this->auth($matches[3]))
|
{
|
{
|
$this->fatal_error("The server did not understand the HELO command");
| |
return false; } }
| return false; } }
|
Zeile 301 | Zeile 352 |
---|
} else {
|
} else {
|
$this->fatal_error("Unable to connect to the mail server with the given details.<br /><br />{$error_number}: {$error_string}");
| $this->fatal_error("Unable to connect to the mail server with the given details. Reason: {$error_number}: {$error_string}");
|
return false; } }
| return false; } }
|
Zeile 316 | Zeile 367 |
---|
{ global $lang, $mybb;
|
{ global $lang, $mybb;
|
$auth_methods = explode(" ", $auth_methods);
| $auth_methods = explode(" ", trim($auth_methods));
|
if(in_array("LOGIN", $auth_methods)) {
| if(in_array("LOGIN", $auth_methods)) {
|
Zeile 387 | Zeile 438 |
---|
break; } }
|
break; } }
|
| $string = trim($string);
|
$this->data = $string;
|
$this->data = $string;
|
$this->code = substr(trim($this->data), 0, 3);
| $this->code = substr($this->data, 0, 3);
|
return $string; }
| return $string; }
|