Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Mailer/SMTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function send(Message $message)
$this->connect()
->ehlo();

if ($this->secure === 'tls' || $this->secure === 'tlsv1.0' || $this->secure === 'tlsv1.1' | $this->secure === 'tlsv1.2') {
if ($this->secure === 'tls' || $this->secure === 'tlsv1.0' || $this->secure === 'tlsv1.1' || $this->secure === 'tlsv1.2') {
$this->starttls()
->ehlo();
}
Expand Down Expand Up @@ -224,7 +224,10 @@ protected function connect()
$context
);
if (!$this->smtp){
throw new SMTPException("Could not open SMTP Port to $host:{$this->port}");
throw new SMTPException(
"Could not open SMTP Port to $host:{$this->port}" .
($error_message ? " ($error_code: $error_message)" : '')
);
}
$code = $this->getCode();
if ($code !== '220'){
Expand Down Expand Up @@ -259,8 +262,12 @@ protected function starttls()
stream_context_set_option($this->smtp, 'ssl', 'allow_self_signed', true);
}

if(!\stream_socket_enable_crypto($this->smtp, true, STREAM_CRYPTO_METHOD_ANY_CLIENT)) {
throw new CryptoException("Start TLS failed to enable crypto");
if(!@\stream_socket_enable_crypto($this->smtp, true, STREAM_CRYPTO_METHOD_ANY_CLIENT)) {
$err = error_get_last();
throw new CryptoException(
"Start TLS failed to enable crypto" .
(isset($err['message']) ? ": {$err['message']}" : '')
);
}
return $this;
}
Expand Down
Loading