From 5de338e45ebca0d055e0bb2a8df4db20fa61c6de Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 17 Oct 2015 07:38:36 -0400
Subject: [PATCH] Update changelog
---
program/lib/Roundcube/rcube_smtp.php | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/program/lib/Roundcube/rcube_smtp.php b/program/lib/Roundcube/rcube_smtp.php
index b37b444..53298e6 100644
--- a/program/lib/Roundcube/rcube_smtp.php
+++ b/program/lib/Roundcube/rcube_smtp.php
@@ -126,10 +126,13 @@
// try to connect to server and exit on failure
$result = $this->conn->connect($CONFIG['smtp_timeout']);
- if (PEAR::isError($result)) {
- $this->response[] = "Connection failed: ".$result->getMessage();
- $this->error = array('label' => 'smtpconnerror', 'vars' => array('code' => $this->conn->_code));
+ if (is_a($result, 'PEAR_Error')) {
+ $this->response[] = "Connection failed: " . $result->getMessage();
+
+ list($code,) = $this->conn->getResponse();
+ $this->error = array('label' => 'smtpconnerror', 'vars' => array('code' => $code));
$this->conn = null;
+
return false;
}
@@ -159,11 +162,15 @@
$result = $this->conn->auth($smtp_user, $smtp_pass, $smtp_auth_type, $use_tls, $smtp_authz);
- if (PEAR::isError($result)) {
- $this->error = array('label' => 'smtpautherror', 'vars' => array('code' => $this->conn->_code));
- $this->response[] .= 'Authentication failure: ' . $result->getMessage() . ' (Code: ' . $result->getCode() . ')';
+ if (is_a($result, 'PEAR_Error')) {
+ list($code,) = $this->conn->getResponse();
+ $this->error = array('label' => 'smtpautherror', 'vars' => array('code' => $code));
+ $this->response[] = 'Authentication failure: ' . $result->getMessage()
+ . ' (Code: ' . $result->getCode() . ')';
+
$this->reset();
$this->disconnect();
+
return false;
}
}
@@ -208,11 +215,6 @@
else if (is_string($headers)) {
$text_headers = $headers;
}
- else {
- $this->reset();
- $this->response[] = "Invalid message headers";
- return false;
- }
// exit if no from address is given
if (!isset($from)) {
@@ -240,7 +242,8 @@
}
// set From: address
- if (PEAR::isError($this->conn->mailFrom($from, $from_params))) {
+ $result = $this->conn->mailFrom($from, $from_params);
+ if (is_a($result, 'PEAR_Error')) {
$err = $this->conn->getResponse();
$this->error = array('label' => 'smtpfromerror', 'vars' => array(
'from' => $from, 'code' => $err[0], 'msg' => $err[1]));
@@ -252,7 +255,7 @@
// prepare list of recipients
$recipients = $this->_parse_rfc822($recipients);
- if (PEAR::isError($recipients)) {
+ if (is_a($recipients, 'PEAR_Error')) {
$this->error = array('label' => 'smtprecipientserror');
$this->reset();
return false;
@@ -260,7 +263,8 @@
// set mail recipients
foreach ($recipients as $recipient) {
- if (PEAR::isError($this->conn->rcptTo($recipient, $recipient_params))) {
+ $result = $this->conn->rcptTo($recipient, $recipient_params);
+ if (is_a($result, 'PEAR_Error')) {
$err = $this->conn->getResponse();
$this->error = array('label' => 'smtptoerror', 'vars' => array(
'to' => $recipient, 'code' => $err[0], 'msg' => $err[1]));
@@ -273,8 +277,11 @@
if (is_resource($body)) {
// file handle
- $data = $body;
- $text_headers = preg_replace('/[\r\n]+$/', '', $text_headers);
+ $data = $body;
+
+ if ($text_headers) {
+ $text_headers = preg_replace('/[\r\n]+$/', '', $text_headers);
+ }
}
else {
// Concatenate headers and body so it can be passed by reference to SMTP_CONN->data
@@ -289,7 +296,7 @@
// Send the message's headers and the body as SMTP data.
$result = $this->conn->data($data, $text_headers);
- if (PEAR::isError($result)) {
+ if (is_a($result, 'PEAR_Error')) {
$err = $this->conn->getResponse();
if (!in_array($err[0], array(354, 250, 221))) {
$msg = sprintf('[%d] %s', $err[0], $err[1]);
--
Gitblit v1.9.1