From f07d238b1b4d75b34639be873dcc1b1627404ae7 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Fri, 28 May 2010 09:54:32 -0400 Subject: [PATCH] - Add 'imap_timeout' option (#1486760) --- program/include/rcube_smtp.php | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-) diff --git a/program/include/rcube_smtp.php b/program/include/rcube_smtp.php index 2bf8cc1..4471435 100644 --- a/program/include/rcube_smtp.php +++ b/program/include/rcube_smtp.php @@ -5,7 +5,7 @@ | program/include/rcube_smtp.php | | | | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | + | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -22,7 +22,15 @@ // define headers delimiter define('SMTP_MIME_CRLF', "\r\n"); -class rcube_smtp { +/** + * Class to provide SMTP functionality using PEAR Net_SMTP + * + * @package Mail + * @author Thomas Bruederli <roundcube@gmail.com> + * @author Aleksander Machniak <alec@alec.pl> + */ +class rcube_smtp +{ private $conn = null; private $response; @@ -124,7 +132,7 @@ $this->error = array('label' => 'smtpautherror', 'vars' => array('code' => $this->conn->_code)); $this->response[] .= 'Authentication failure: ' . $result->getMessage() . ' (Code: ' . $result->getCode() . ')'; $this->reset(); - $this->disconnect(); + $this->disconnect(); return false; } } @@ -233,7 +241,13 @@ // Send the message's headers and the body as SMTP data. if (PEAR::isError($result = $this->conn->data($data, $text_headers))) { - $this->error = array('label' => 'smtperror', 'vars' => array('msg' => $result->getMessage())); + $err = $this->conn->getResponse(); + if (!in_array($err[0], array(354, 250, 221))) + $msg = sprintf('[%d] %s', $err[0], $err[1]); + else + $msg = $result->getMessage(); + + $this->error = array('label' => 'smtperror', 'vars' => array('msg' => $msg)); $this->response[] .= "Failed to send data"; $this->reset(); return false; @@ -386,14 +400,14 @@ $addresses = array(); $recipients = rcube_explode_quoted_string(',', $recipients); - + reset($recipients); while (list($k, $recipient) = each($recipients)) { $a = explode(" ", $recipient); while (list($k2, $word) = each($a)) { - if ((strpos($word, "@") > 0) && (strpos($word, "\"")===false)) + if (strpos($word, "@") > 0 && $word[strlen($word)-1] != '"') { $word = preg_replace('/^<|>$/', '', trim($word)); if (in_array($word, $addresses)===false) @@ -405,5 +419,3 @@ } } - -?> -- Gitblit v1.9.1