Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #30 - fixed @BMintern's indentions #50

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 24 additions & 1 deletion inc/mailhandlers/smtp.php
Expand Up @@ -94,6 +94,13 @@ class SmtpMail extends MailHandler
*/
public $secure_port = 465;

/**
* Whether to use a TLS connection.
*
* @var boolean
*/
public $use_tls = false;

/**
* SMTP host.
*
Expand Down Expand Up @@ -140,7 +147,7 @@ function __construct()
$protocol = 'ssl://';
break;
case MYBB_TLS:
$protocol = 'tls://';
$this->use_tls = true;
break;
}

Expand Down Expand Up @@ -274,6 +281,22 @@ function connect()
return false;
}

if($this->use_tls)
{
$data = $this->send_data('STARTTLS', '220');
if(!$data)
{
$this->fatal_error("Couldn't switch SMTP to TLS");
return false;
}
$data = stream_socket_enable_crypto($this->connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
if(!$data)
{
$this->fatal_error("Couldn't switch socket to TLS");
return false;
}
}

if(!empty($this->username) && !empty($this->password))
{
$data = $this->send_data('EHLO ' . $this->helo, '250');
Expand Down