Skip to content

Commit

Permalink
Merge pull request #1258 from madhurjain/master
Browse files Browse the repository at this point in the history
Fix for SMTP TLS based Auth
  • Loading branch information
Daniel Kerr committed Mar 17, 2014
2 parents a091cfd + b0fa7c0 commit c14a3c0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions upload/system/library/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ public function send() {
break;
}
}

fputs($handle, 'EHLO ' . getenv('SERVER_NAME') . "\r\n");

$reply = '';

while ($line = fgets($handle, 515)) {
$reply .= $line;

if (substr($line, 3, 1) == ' ') {
break;
}
}

if (substr($reply, 0, 3) != 250) {
trigger_error('Error: EHLO not accepted from server!');
exit();
}

if (substr($this->hostname, 0, 3) == 'tls') {
fputs($handle, 'STARTTLS' . "\r\n");
Expand All @@ -188,6 +205,8 @@ public function send() {
trigger_error('Error: STARTTLS not accepted from server!');
exit();
}

stream_socket_enable_crypto($handle, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
}

if (!empty($this->username) && !empty($this->password)) {
Expand Down

0 comments on commit c14a3c0

Please sign in to comment.