From aa12df20e46ae72467f8d4dc01784a500eb83f0c Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 01 Apr 2010 02:39:06 -0400
Subject: [PATCH] Add server-side plugin hooks to address group functions + better action names
---
program/include/rcube_smtp.php | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/program/include/rcube_smtp.php b/program/include/rcube_smtp.php
index 2991262..1dfe222 100644
--- a/program/include/rcube_smtp.php
+++ b/program/include/rcube_smtp.php
@@ -82,6 +82,12 @@
if (isset($smtp_host_url['host']) && isset($smtp_host_url['scheme']))
$smtp_host = sprintf('%s://%s', $smtp_host_url['scheme'], $smtp_host_url['host']);
+ // remove TLS prefix and set flag for use in Net_SMTP::auth()
+ if (preg_match('#^tls://#i', $smtp_host)) {
+ $smtp_host = preg_replace('#^tls://#i', '', $smtp_host);
+ $use_tls = true;
+ }
+
if (!empty($CONFIG['smtp_helo_host']))
$helo_host = $CONFIG['smtp_helo_host'];
else if (!empty($_SERVER['SERVER_NAME']))
@@ -107,11 +113,12 @@
$smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']);
$smtp_pass = str_replace('%p', $RCMAIL->decrypt($_SESSION['password']), $CONFIG['smtp_pass']);
$smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type'];
-
+
// attempt to authenticate to the SMTP server
if ($smtp_user && $smtp_pass)
{
- $result = $this->conn->auth($smtp_user, $smtp_pass, $smtp_auth_type);
+ $result = $this->conn->auth($smtp_user, $smtp_pass, $smtp_auth_type, $use_tls);
+
if (PEAR::isError($result))
{
$this->error = array('label' => 'smtpautherror', 'vars' => array('code' => $this->conn->_code));
@@ -226,7 +233,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 (count($err)>1 && $err[0] != 354 && $err[0] != 250)
+ $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;
@@ -379,14 +392,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)
@@ -398,5 +411,3 @@
}
}
-
-?>
--
Gitblit v1.9.1