Aleksander Machniak
2015-01-28 78f948f7b9838de6d62c76f4daf6834244ae1348
Make logged SMTP errors more verbose - log also real server response and codes
2 files modified
16 ■■■■■ changed files
program/lib/Roundcube/rcube.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_smtp.php 14 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube.php
@@ -1503,7 +1503,7 @@
            if (!$sent) {
                self::raise_error(array('code' => 800, 'type' => 'smtp',
                    'line' => __LINE__, 'file' => __FILE__,
                    'message' => "SMTP error: ".join("\n", $response)), TRUE, FALSE);
                    'message' => join("\n", $response)), true, false);
            }
        }
        // send mail using PHP's mail() function
program/lib/Roundcube/rcube_smtp.php
@@ -243,8 +243,9 @@
        if (PEAR::isError($this->conn->mailFrom($from, $from_params))) {
            $err = $this->conn->getResponse();
            $this->error = array('label' => 'smtpfromerror', 'vars' => array(
                'from' => $from, 'code' => $this->conn->_code, 'msg' => $err[1]));
            $this->response[] = "Failed to set sender '$from'";
                'from' => $from, 'code' => $err[0], 'msg' => $err[1]));
            $this->response[] = "Failed to set sender '$from'. "
                . $err[1] . ' (Code: ' . $err[0] . ')';
            $this->reset();
            return false;
        }
@@ -262,8 +263,9 @@
            if (PEAR::isError($this->conn->rcptTo($recipient, $recipient_params))) {
                $err = $this->conn->getResponse();
                $this->error = array('label' => 'smtptoerror', 'vars' => array(
                    'to' => $recipient, 'code' => $this->conn->_code, 'msg' => $err[1]));
                $this->response[] = "Failed to add recipient '$recipient'";
                    'to' => $recipient, 'code' => $err[0], 'msg' => $err[1]));
                $this->response[] = "Failed to add recipient '$recipient'. "
                    . $err[1] . ' (Code: ' . $err[0] . ')';
                $this->reset();
                return false;
            }
@@ -286,7 +288,7 @@
        }
        // Send the message's headers and the body as SMTP data.
        if (PEAR::isError($result = $this->conn->data($data, $text_headers))) {
        if (PEAR::isError($this->conn->data($data, $text_headers))) {
            $err = $this->conn->getResponse();
            if (!in_array($err[0], array(354, 250, 221))) {
                $msg = sprintf('[%d] %s', $err[0], $err[1]);
@@ -296,7 +298,7 @@
            }
            $this->error = array('label' => 'smtperror', 'vars' => array('msg' => $msg));
            $this->response[] = "Failed to send data";
            $this->response[] = "Failed to send data. " . $msg;
            $this->reset();
            return false;
        }