Use new Horde_Mail:: package
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 12 May 2010 03:58:26 +0000 (21:58 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 12 May 2010 05:50:00 +0000 (23:50 -0600)
Resolves Request #8909 (pass stream to send())

55 files changed:
agora/messages/abuse.php
ansel/img/ecard.php
ansel/lib/Report/mail.php
babel/lib/Babel.php
folks/lib/Folks.php
folks/lib/Notification/mail.php
framework/Alarm/lib/Horde/Alarm/Handler/Mail.php
framework/Alarm/package.xml
framework/Alarm/test/Horde/Alarm/HandlerTest.php
framework/Auth/lib/Horde/Auth/Signup.php
framework/Core/lib/Horde/Core/Binder/Alarm.php
framework/Core/lib/Horde/Core/Binder/Mail.php
framework/Core/lib/Horde/Registry.php
framework/Data/Data/tsv.php
framework/Data/package.xml
framework/Form/Form/Type.php
framework/Mime/lib/Horde/Mime/Address.php
framework/Mime/lib/Horde/Mime/Mail.php
framework/Mime/lib/Horde/Mime/Mail/mail.php [deleted file]
framework/Mime/lib/Horde/Mime/Mail/sendmail.php [deleted file]
framework/Mime/lib/Horde/Mime/Mail/smtp.php [deleted file]
framework/Mime/lib/Horde/Mime/Mail/smtpmx.php [deleted file]
framework/Mime/lib/Horde/Mime/Part.php
framework/Mime/package.xml
framework/Model/lib/Horde/Form.php
framework/Model/lib/Horde/Form/Type/Email.php
framework/Net_SMS/SMS/generic_smtp.php
framework/Net_SMS/SMS/vodafoneitaly_smtp.php
framework/Net_SMS/package.xml
framework/Prefs/lib/Horde/Prefs/Identity.php
framework/iCalendar/iCalendar/vcard.php
framework/iCalendar/package.xml
horde/config/hooks.php.dist
horde/docs/CHANGES
horde/docs/INSTALL
horde/docs/UPGRADING
horde/lib/Test.php
horde/rpc.php
horde/services/problem.php
horde/services/resetpassword.php
imp/docs/CHANGES
imp/lib/Application.php
imp/lib/Compose.php
imp/lib/Injector/Binder/Mail.php [new file with mode: 0644]
imp/lib/Mime/Viewer/Itip.php
imp/lib/Ui/Message.php
kronolith/lib/FreeBusy.php
kronolith/lib/Kronolith.php
kronolith/scripts/agenda.php
nag/lib/Nag.php
news/mail.php
turba/data.php
turba/scripts/upgrades/2.1_to_2.2_sql_schema.php
whups/lib/Driver.php
wicked/lib/Wicked.php

index 1774bd8..66571d2 100644 (file)
@@ -77,7 +77,7 @@ if ($form->validate()) {
         'from' => $emails[0],
         'charset' => Horde_Nls::getCharset()));
     $mail->addHeader('User-Agent', 'Agora ' . $registry->getVersion());
-    $mail->send($injector->getInstance('Mail'));
+    $mail->send($injector->getInstance('Horde_Mail'));
 
     $notification->push($subject, 'horde.success');
     header('Location: ' . $url);
index a4247a9..f91f3d8 100644 (file)
@@ -83,7 +83,7 @@ case 'send':
     $alt->setBasePart($alternative);
 
     /* Send. */
-    $result = $alt->send($injector->getInstance('Mail'));
+    $result = $alt->send($injector->getInstance('Horde_Mail'));
     if (is_a($result, 'PEAR_Error')) {
         $notification->push(sprintf(_("There was an error sending your message: %s"), $result->getMessage()), 'horde.error');
     } else {
index 0db2997..cf37ba5 100644 (file)
@@ -37,6 +37,6 @@ class Ansel_Report_mail extends Ansel_Report {
         //FIXME: This address should be configurable
         $mail->addHeader('Sender',
                          'horde-problem@' . $conf['report_content']['maildomain']);
-        return $mail->send($GLOBALS['injector']->getInstance('Mail'));
+        return $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
     }
 }
index bc76cec..c3b2c1f 100644 (file)
@@ -258,8 +258,7 @@ class Babel {
        $body = $mime->get();
        $hdrs = $mime->headers($headers);
 
-       $mail_object = &Mail::factory("mail");
-       return $mail_object->send($email['to'], $hdrs, $body);
+       return $GLOBALS['injector']->getInstance('Horde_Mail')->send($email['to'], $hdrs, $body);
     }
 
 
index 6a84b06..35b0795 100644 (file)
@@ -247,7 +247,7 @@ class Folks {
             }
         }
 
-        return $mail->send($GLOBALS['injector']->getInstance('Mail'));
+        return $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
     }
 
     /**
index 64ff854..459d414 100644 (file)
@@ -79,7 +79,7 @@ class Folks_Notification_mail extends Folks_Notification {
                 continue;
             }
             $mail->addHeader('To', $to, Horde_Nls::getCharset(), true);
-            $mail->send($GLOBALS['injector']->getInstance('Mail'));
+            $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
         }
 
         return true;
index 30854b7..d751054 100644 (file)
@@ -25,9 +25,9 @@ class Horde_Alarm_Handler_Mail extends Horde_Alarm_Handler
     protected $_identity;
 
     /**
-     * A Mail object.
+     * A Horde_Mail_Driver object.
      *
-     * @var Mail
+     * @var Horde_Mail_Driver
      */
     protected $_mail;
 
@@ -45,7 +45,7 @@ class Horde_Alarm_Handler_Mail extends Horde_Alarm_Handler
      *                       Required parameter:
      *                       - identity: An identity factory that implements
      *                                   getIdentity().
-     *                       - mail: A PEAR Mail instance.
+     *                       - mail: A Horde_Mail_Driver instance.
      *                       - charset: The charset of the messages.
      */
     public function __construct(array $params = null)
@@ -59,8 +59,8 @@ class Horde_Alarm_Handler_Mail extends Horde_Alarm_Handler
             throw new Horde_Alarm_Exception('Parameter \'identity\' does not implement getIdentity().');
         }
         $r = new ReflectionObject($params['mail']);
-        if (!($params['mail'] instanceof Mail)) {
-            throw new Horde_Alarm_Exception('Parameter \'mail\' is not a Mail object.');
+        if (!($params['mail'] instanceof Horde_Mail_Driver)) {
+            throw new Horde_Alarm_Exception('Parameter \'mail\' is not a Horde_Mail_Driver object.');
         }
         $this->_identity = $params['identity'];
         $this->_mail     = $params['mail'];
index 1f5d5b4..1c5b526 100644 (file)
   </required>
   <optional>
    <package>
+    <name>Mail</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Mime</name>
     <channel>pear.horde.org</channel>
    </package>
index 17df329..d06472c 100644 (file)
@@ -19,8 +19,8 @@ class Horde_Alarm_HandlerTest extends PHPUnit_Framework_TestCase
             $this->markTestSkipped('Horde_Notification not installed');
             return;
         }
-        if (!class_exists('Mail')) {
-            $this->markTestSkipped('Mail not installed');
+        if (!class_exists('Horde_Mail')) {
+            $this->markTestSkipped('Horde_Mail not installed');
             return;
         }
 
@@ -44,7 +44,7 @@ class Horde_Alarm_HandlerTest extends PHPUnit_Framework_TestCase
         $handler = new Horde_Alarm_Handler_Desktop(array('notification' => $notification, 'icon' => 'test.png'));
         self::$alarm->addHandler('desktop', $handler);
 
-        self::$mail = new Horde_Alarm_HandlerTest_Mail();
+        self::$mail = Horde_Mail::factory('Mock');
         $factory = new Horde_Alarm_HandlerTest_IdentityFactory();
         $handler = new Horde_Alarm_Handler_Mail(array('mail' => self::$mail, 'identity' => $factory, 'charset' => 'us-ascii'));
         self::$alarm->addHandler('mail', $handler);
@@ -85,15 +85,21 @@ Action is required\.
 EOR;
         $regexp = trim(str_replace("\r\n", "\n", $regexp));
 
-        $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", self::$mail->sentOutput)));
-        self::$mail->sentOutput = null;
+        $last_sent = end(self::$mail->sentMessages);
+        $sent_message = $last_sent['header_text'] . "\n\n" . $last_sent['body'];
+        $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", $sent_message)));
+
+        self::$mail->sentMessages = array();
         self::$alarm->notify('john', false);
-        $this->assertNull(self::$mail->sentOutput);
+        $this->assertEquals(self::$mail->sentMessages, array());
 
         /* Test re-sending mails after changing the alarm. */
         self::$alarm->set(self::$alarm->get('personalalarm', 'john'));
         self::$alarm->notify('john', false);
-        $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", self::$mail->sentOutput)));
+
+        $last_sent = end(self::$mail->sentMessages);
+        $sent_message = $last_sent['header_text'] . "\n\n" . $last_sent['body'];
+        $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", $sent_message)));
     }
 }
 
@@ -112,14 +118,3 @@ class Horde_Alarm_HandlerTest_Identity
         return 'john@example.com';
     }
 }
-
-class Horde_Alarm_HandlerTest_Mail extends Mail
-{
-    public $sentOutput;
-
-    public function send($recipients, $headers, $body)
-    {
-        list(, $textHeaders) = Mail::prepareHeaders($headers);
-        $this->sentOutput = $textHeaders . "\n\n" . $body;
-    }
-}
index 4b86754..34533b0 100644 (file)
@@ -134,7 +134,7 @@ class Horde_Auth_Signup
                 'to' => $conf['signup']['email'],
                 'from' => $conf['signup']['email'],
                 'subject' => Horde_Nls::getCharset()));
-            $mail->send($GLOBALS['injector']->getInstance('Mail'));
+            $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
         }
     }
 
index 56b24b5..21e07b4 100644 (file)
@@ -30,7 +30,7 @@ class Horde_Core_Binder_Alarm implements Horde_Injector_Binder
         */
         $handler_params = array(
             'identity' => $injector->getInstance('Horde_Prefs_Identity'),
-            'mail' => $injector->getInstance('Mail'),
+            'mail' => $injector->getInstance('Horde_Mail'),
             'charset' => Horde_Nls::getCharset());
         $alarm->addHandler('mail', new Horde_Alarm_Handler_Mail($handler_params));
 
index a8d7ea5..be04e64 100644 (file)
@@ -22,7 +22,7 @@ class Horde_Core_Binder_Mail implements Horde_Injector_Binder
         }
 
         try {
-            return Horde_Mime_Mail::getMailOb($driver, $params);
+            return Horde_Mail::factory($driver, $params);
         } catch (Horde_Mime_Exception $e) {
             throw new Horde_Exception($e);
         }
index 20a1e57..0c3be2d 100644 (file)
@@ -241,6 +241,7 @@ class Horde_Registry
             'Horde_History' => new Horde_Core_Binder_History(),
             'Horde_Lock' => new Horde_Core_Binder_Lock(),
             'Horde_Log_Logger' => new Horde_Core_Binder_Logger(),
+            'Horde_Mail' => new Horde_Core_Binder_Mail(),
             'Horde_Memcache' => new Horde_Core_Binder_Memcache(),
             'Horde_Notification' => new Horde_Core_Binder_Notification(),
             'Horde_Perms' => new Horde_Core_Binder_Perms(),
@@ -250,7 +251,6 @@ class Horde_Registry
             'Horde_Template' => new Horde_Core_Binder_Template(),
             'Horde_Token' => new Horde_Core_Binder_Token(),
             'Horde_Vfs' => new Horde_Core_Binder_Vfs(),
-            'Mail' => new Horde_Core_Binder_Mail(),
             'Net_DNS_Resolver' => new Horde_Core_Binder_Dns()
         );
 
index 7779a54..3b79404 100644 (file)
@@ -157,10 +157,12 @@ class Horde_Data_tsv extends Horde_Data {
                         }
                         $row[1] = preg_replace('/^([^,"]+),\s*(.*)$/', '$2 $1', $row[1]);
                         /* Address can be a full RFC822 address */
-                        require_once 'Horde/MIME.php';
-                        $addr_arr = MIME::parseAddressList($row[2]);
-                        if (is_a($addr_arr, 'PEAR_Error') ||
-                            empty($addr_arr[0]->mailbox)) {
+                        try {
+                            $addr_arr = Horde_Mime_Address::parseAddressList($row[2]);
+                        } catch (Horde_Mime_Exception $e) {
+                            continue;
+                        }
+                        if (empty($addr_arr[0]->mailbox)) {
                             continue;
                         }
                         $row[2] = $addr_arr[0]->mailbox . '@' . $addr_arr[0]->host;
index 3601f63..fe19682 100644 (file)
@@ -13,7 +13,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
 * vCard
 * vNote
 * vTodo
-  
  </description>
  <lead>
   <name>Jan Schneider</name>
@@ -63,17 +62,17 @@ http://pear.php.net/dtd/package-2.0.xsd">
  <dependencies>
   <required>
    <php>
-    <min>4.2.0</min>
+    <min>5.2.0</min>
    </php>
    <pearinstaller>
-    <min>1.4.0b1</min>
+    <min>1.7.0</min>
    </pearinstaller>
    <package>
     <name>iCalendar</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Horde_MIME</name>
+    <name>Mime</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
index be70e40..713413c 100644 (file)
@@ -2069,10 +2069,10 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
             $message = _("Email addresses must match.");
             return false;
         } else {
-            $parsed_email = Horde_Mime_Address::parseAddressList($value['original'],
-                                                                 array('validate' => true));
-            if (is_a($parsed_email, 'PEAR_Error')) {
-                $message = $parsed_email->getMessage();
+            try {
+                $parsed_email = Horde_Mime_Address::parseAddressList($value['original'], array('validate' => true));
+            } catch (Horde_Mime_Exception $e) {
+                $message = $e->getMessage();
                 return false;
             }
             if (count($parsed_email) > 1) {
index 12621e4..17c056d 100644 (file)
 class Horde_Mime_Address
 {
     /**
+     * RFC 822 parser instance.
+     *
+     * @var Horde_Mail_Rfc822
+     */
+    static protected $_rfc822;
+
+    /**
      * Builds an RFC compliant email address.
      *
      * @param string $mailbox   Mailbox name.
@@ -374,20 +381,24 @@ class Horde_Mime_Address
             return array();
         }
 
+        if (!self::$_rfc822) {
+            self::$_rfc822 = new Horde_Mail_Rfc822();
+        }
+
         $options = array_merge(array(
             'defserver' => null,
             'nestgroups' => false,
             'validate' => false
         ), $options);
 
-        static $parser;
-        if (!isset($parser)) {
-            $parser = new Mail_RFC822();
-        }
-
-        $ret = $parser->parseAddressList($address, $options['defserver'], $options['nestgroups'], $options['validate']);
-        if (is_a($ret, 'PEAR_Error')) {
-            throw new Horde_Mime_Exception($ret);
+        try {
+            $ret = self::$_rfc822->parseAddressList($address, array(
+                'default_domain' => $options['defserver'],
+                'nest_groups' => $options['nestgroups'],
+                'validate' => $options['validate']
+            ));
+        } catch (Horde_Mail_Exception $e) {
+            throw new Horde_Mime_Exception($e);
         }
 
         /* Convert objects to arrays. */
index 3504d88..6eeb0ff 100644 (file)
@@ -473,147 +473,4 @@ class Horde_Mime_Mail
                                $this->_headers, $mailer);
     }
 
-    /**
-     * Utility function to create a Mail object.
-     *
-     * @param string $driver  The mail driver.
-     * @param array $params   The mail parameters.
-     * @param array $options  Additional options:
-     * <pre>
-     * 'raw' - (array) If set, will use the value contained in 'headertext'
-     *         as the exact data to use for the message header. Additionally,
-     *         the 'from' key should contain the From address to use.
-     * </pre>
-     *
-     * @return Mail  A Mail object.
-     * @throws Horde_Mime_Exception
-     */
-    static public function getMailOb($driver, $params, $options = array())
-    {
-        if (!empty($options['raw'])) {
-            switch ($driver) {
-            case 'mail':
-            case 'sendmail':
-            case 'smtp':
-            case 'smtpmx':
-                /* Can't autoload - Mail doesn't support it. */
-                require_once dirname(__FILE__) . '/Mail/' . $driver . '.php';
-                $driver = 'horde_mime_' . $driver;
-                $params['from'] = empty($options['raw']['from'])
-                    ? ''
-                    : $options['raw']['from'];
-                $params['headertext'] = empty($options['raw']['headertext'])
-                    ? ''
-                    : $options['raw']['headertext'];
-                break;
-            }
-        }
-
-        $mailer = Mail::factory($driver, $params);
-        if ($mailer instanceof PEAR_Error) {
-            throw new Horde_Mime_Exception($mailer);
-        }
-
-        return $mailer;
-    }
-
-    /**
-     * Utility function to send a message using a PEAR Mail driver. Handles
-     * errors from this class.
-     *
-     * @param Mail $mailer    A Mail object.
-     * @param string $email   The address list to send to.
-     * @param array $headers  An array of message headers.
-     * @param string $msg     The message text.
-     *
-     * @throws Horde_Mime_Exception
-     */
-    static public function sendPearMail($mailer, $email, $headers, $msg)
-    {
-        $result = $mailer->send($email, $headers, $msg);
-
-        if (!$result instanceof PEAR_Error) {
-            return;
-        }
-
-        if (!($mailer instanceof Mail_sendmail)) {
-            throw new Horde_Mime_Exception($result);
-        }
-
-        switch ($result->getCode()) {
-        case 64: // EX_USAGE
-            $msg = 'command line usage error';
-            break;
-
-        case 65: // EX_DATAERR
-            $msg =  'data format error';
-            break;
-
-        case 66: // EX_NOINPUT
-            $msg = 'cannot open input';
-            break;
-
-        case 67: // EX_NOUSER
-            $msg = 'addressee unknown';
-            break;
-
-        case 68: // EX_NOHOST
-            $msg = 'host name unknown';
-            break;
-
-        case 69: // EX_UNAVAILABLE
-            $msg = 'service unavailable';
-            break;
-
-        case 70: // EX_SOFTWARE
-            $msg = 'internal software error';
-            break;
-
-        case 71: // EX_OSERR
-            $msg = 'system error';
-            break;
-
-        case 72: // EX_OSFILE
-            $msg = 'critical system file missing';
-            break;
-
-        case 73: // EX_CANTCREAT
-            $msg = 'cannot create output file';
-            break;
-
-        case 74: // EX_IOERR
-            $msg = 'input/output error';
-            break;
-
-        case 75: // EX_TEMPFAIL
-            $msg = 'temporary failure';
-            break;
-
-        case 76: // EX_PROTOCOL
-            $msg = 'remote error in protocol';
-            break;
-
-        case 77: // EX_NOPERM
-            $msg = 'permission denied';
-            break;
-
-        case 77: // EX_NOPERM
-            $msg = 'permission denied';
-            break;
-
-        case 78: // EX_CONFIG
-            $msg = 'configuration error';
-            break;
-
-        case 79: // EX_NOTFOUND
-            $msg = 'entry not found';
-            break;
-
-        default:
-            throw new Horde_Mime_Exception($result);
-        }
-
-        throw new Horde_Mime_Exception('sendmail: ' . $msg . ' (' . $result->getCode() . ')');
-    }
-
 }
diff --git a/framework/Mime/lib/Horde/Mime/Mail/mail.php b/framework/Mime/lib/Horde/Mime/Mail/mail.php
deleted file mode 100644 (file)
index df4003c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Extends mail Mail driver by allowing unaltered headers to be sent.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Mime
- */
-class Mail_horde_mime_mail extends Mail_mail
-{
-    /**
-     * The From address to use.
-     *
-     * @var string
-     */
-    protected $_from;
-
-    /**
-     * The raw headertext to use.
-     *
-     * @var string
-     */
-    protected $_headertext;
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters:
-     * <pre>
-     * 'from' - (string) The From address to use.
-     * 'headertext' - (string) The raw headertext to use.
-     * </pre>
-     */
-    public function __construct($params)
-    {
-        $this->_from = $params['from'];
-        $this->_headertext = $params['headertext'];
-        unset($params['from'], $params['headertext']);
-
-        parent::__construct($params);
-    }
-
-    /**
-     * Prepare headers for sending.
-     *
-     * @param array $headers  The headers array (not used).
-     *
-     * @return array  2 elements: the from address and the header text.
-     */
-    public function prepareHeaders($headers)
-    {
-        return array($this->_from, $this->_headertext);
-    }
-
-}
diff --git a/framework/Mime/lib/Horde/Mime/Mail/sendmail.php b/framework/Mime/lib/Horde/Mime/Mail/sendmail.php
deleted file mode 100644 (file)
index 9e0b9ac..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Extends Sendmail Mail driver by allowing unaltered headers to be sent.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Mime
- */
-class Mail_horde_mime_sendmail extends Mail_sendmail
-{
-    /**
-     * The From address to use.
-     *
-     * @var string
-     */
-    protected $_from;
-
-    /**
-     * The raw headertext to use.
-     *
-     * @var string
-     */
-    protected $_headertext;
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters:
-     * <pre>
-     * 'from' - (string) The From address to use.
-     * 'headertext' - (string) The raw headertext to use.
-     * </pre>
-     */
-    public function __construct($params)
-    {
-        $this->_from = $params['from'];
-        $this->_headertext = $params['headertext'];
-        unset($params['from'], $params['headertext']);
-
-        parent::__construct($params);
-    }
-
-    /**
-     * Prepare headers for sending.
-     *
-     * @param array $headers  The headers array (not used).
-     *
-     * @return array  2 elements: the from address and the header text.
-     */
-    public function prepareHeaders($headers)
-    {
-        return array($this->_from, $this->_headertext);
-    }
-
-}
diff --git a/framework/Mime/lib/Horde/Mime/Mail/smtp.php b/framework/Mime/lib/Horde/Mime/Mail/smtp.php
deleted file mode 100644 (file)
index f6025dc..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Extends Smtp Mail driver by allowing unaltered headers to be sent.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Mime
- */
-class Mail_horde_mime_smtp extends Mail_smtp
-{
-    /**
-     * The From address to use.
-     *
-     * @var string
-     */
-    protected $_from;
-
-    /**
-     * The raw headertext to use.
-     *
-     * @var string
-     */
-    protected $_headertext;
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters:
-     * <pre>
-     * 'from' - (string) The From address to use.
-     * 'headertext' - (string) The raw headertext to use.
-     * </pre>
-     */
-    public function __construct($params)
-    {
-        $this->_from = $params['from'];
-        $this->_headertext = $params['headertext'];
-        unset($params['from'], $params['headertext']);
-
-        parent::__construct($params);
-    }
-
-    /**
-     * Prepare headers for sending.
-     *
-     * @param array $headers  The headers array (not used).
-     *
-     * @return array  2 elements: the from address and the header text.
-     */
-    public function prepareHeaders($headers)
-    {
-        return array($this->_from, $this->_headertext);
-    }
-
-}
diff --git a/framework/Mime/lib/Horde/Mime/Mail/smtpmx.php b/framework/Mime/lib/Horde/Mime/Mail/smtpmx.php
deleted file mode 100644 (file)
index 99bdef7..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Extends Smtpmx Mail driver by allowing unaltered headers to be sent.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Mime
- */
-class Mail_horde_mime_smtpmx extends Mail_smtpmx
-{
-    /**
-     * The From address to use.
-     *
-     * @var string
-     */
-    protected $_from;
-
-    /**
-     * The raw headertext to use.
-     *
-     * @var string
-     */
-    protected $_headertext;
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters:
-     * <pre>
-     * 'from' - (string) The From address to use.
-     * 'headertext' - (string) The raw headertext to use.
-     * </pre>
-     */
-    public function __construct($params)
-    {
-        $this->_from = $params['from'];
-        $this->_headertext = $params['headertext'];
-        unset($params['from'], $params['headertext']);
-
-        parent::__construct($params);
-    }
-
-    /**
-     * Prepare headers for sending.
-     *
-     * @param array $headers  The headers array (not used).
-     *
-     * @return array  2 elements: the from address and the header text.
-     */
-    public function prepareHeaders($headers)
-    {
-        return array($this->_from, $this->_headertext);
-    }
-
-}
index 98ac9da..3cf296f 100644 (file)
@@ -1471,42 +1471,48 @@ class Horde_Mime_Part
      * @param string $email                The address list to send to.
      * @param Horde_Mime_Headers $headers  The Horde_Mime_Headers object
      *                                     holding this message's headers.
-     * @param Mail $mailer                 A Mail driver.
+     * @param Horde_Mail_Driver $mailer    A Horde_Mail_Driver object.
      *
      * @throws Horde_Mime_Exception
      * @throws InvalidArgumentException
      */
     public function send($email, $headers, $mailer)
     {
-        if (!($mailer instanceof Mail)) {
-            throw new InvalidArgumentException('Invalid Mail object passed to send().');
+        if (!($mailer instanceof Horde_Mail_Driver)) {
+            throw new InvalidArgumentException('Invalid Horde_Mail_Driver object passed to send().');
         }
 
         $old_basepart = $this->_basepart;
         $this->_basepart = true;
 
         /* Does the SMTP backend support 8BITMIME (RFC 1652) or
-         * BINARYMIME (RFC 3030) extensions? Requires PEAR's Mail package
-         * version 1.2+ and Net_SMTP version 1.3+. */
+         * BINARYMIME (RFC 3030) extensions? Requires Net_SMTP version
+         * 1.3+. */
         $encode = self::ENCODE_7BIT;
-        if ($mailer instanceof Mail_smtp) {
-            $net_smtp = $mailer->getSMTPObject();
-            if (!($net_smtp instanceof PEAR_Error)) {
-                $smtp_ext = $net_smtp->getServiceExtensions();
+        if ($mailer instanceof Horde_Mail_Smtp) {
+            try {
+                $smtp_ext = $mailer->getSMTPObject()->getServiceExtensions();
                 if (isset($smtp_ext['8BITMIME'])) {
                     $encode |= self::ENCODE_8BIT;
                 }
                 if (isset($smtp_ext['BINARYMIME'])) {
                     $encode |= self::ENCODE_BINARY;
                 }
-            }
+            } catch (Horde_Mail_Exception $e) {}
         }
 
+        $msg = $this->toString(array(
+            'encode' => $encode,
+            'headers' => false,
+            'stream' => true
+        ));
+
         /* Make sure the message has a trailing newline. */
-        $msg = $this->toString(array('encode' => $encode, 'headers' => false));
-        if (substr($msg, -1) != "\n") {
-            $msg .= "\n";
+        fseek($msg, -1, SEEK_END);
+        if (fgetc($msg) != "\n") {
+            fputs($msg, "\n");
         }
+        rewind($msg);
 
         /* Add MIME Headers if they don't already exist. */
         if (!$headers->getValue('MIME-Version')) {
@@ -1528,7 +1534,11 @@ class Horde_Mime_Part
 
         $this->_basepart = $old_basepart;
 
-        Horde_Mime_Mail::sendPearMail($mailer, Horde_Mime::encodeAddress($email, $this->getCharset()), $headers->toArray(array('charset' => $this->getHeaderCharset())), $msg);
+        try {
+            $mailer->send(Horde_Mime::encodeAddress($email, $this->getCharset()), $headers->toArray(array('charset' => $this->getHeaderCharset())), $msg);
+        } catch (Horde_Mail_Exception $e) {
+            throw new Horde_Mime_Exception($e);
+        }
     }
 
     /**
index 2f12530..a1ad7b1 100644 (file)
@@ -31,8 +31,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>alpha</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add Mail driver extensions (raw header output).
- * No need to generate Content-Transfer-Encoding header if part data is 7bit.
+ <notes>* No need to generate Content-Transfer-Encoding header if part data is 7bit.
  * Default disposition should be empty by default, not inline (RFC 2183 [2]).
  * Request #8556: Allow specifying a header charset for a part.
  * Add 'raw' render view to Horde_Mime_Viewer.
@@ -49,12 +48,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <dir name="lib">
     <dir name="Horde">
      <dir name="Mime">
-      <dir name="Mail">
-       <file name="mail.php" role="php" />
-       <file name="sendmail.php" role="php" />
-       <file name="smtp.php" role="php" />
-       <file name="smtpmx.php" role="php" />
-      </dir> <!-- /lib/Horde/Mime/Mail -->
       <dir name="Viewer">
        <dir name="Ooo">
         <file name="common.xsl" role="php" />
@@ -173,8 +166,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
    </package>
    <package>
     <name>Mail</name>
-    <channel>pear.php.net</channel>
-    <min>1.2.0</min>
+    <channel>pear.horde.org</channel>
    </package>
    <package>
     <name>Stream_Filter</name>
@@ -222,10 +214,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </dependencies>
  <phprelease>
   <filelist>
-   <install name="lib/Horde/Mime/Mail/mail.php" as="Horde/Mime/Mail/mail.php" />
-   <install name="lib/Horde/Mime/Mail/sendmail.php" as="Horde/Mime/Mail/sendmail.php" />
-   <install name="lib/Horde/Mime/Mail/smtp.php" as="Horde/Mime/Mail/smtp.php" />
-   <install name="lib/Horde/Mime/Mail/smtpmx.php" as="Horde/Mime/Mail/smtpmx.php" />
    <install name="lib/Horde/Mime/Viewer/Ooo/common.xsl" as="Horde/Mime/Viewer/Ooo/common.xsl" />
    <install name="lib/Horde/Mime/Viewer/Ooo/global_document.xsl" as="Horde/Mime/Viewer/Ooo/global_document.xsl" />
    <install name="lib/Horde/Mime/Viewer/Ooo/main_html.xsl" as="Horde/Mime/Viewer/Ooo/main_html.xsl" />
index 4ba9b04..6eec231 100644 (file)
@@ -1661,8 +1661,10 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
             $message = _("Email addresses must match.");
             return false;
         } else {
-            $parser = new Mail_RFC822();
-            $parsed_email = $parser->parseAddressList($value['original'], false, true);
+            $parser = new Horde_Mail_Rfc822();
+            $parsed_email = $parser->parseAddressList($value['original'], array(
+                'default_domain' => false
+            ));
 
             if (count($parsed_email) > 1) {
                 $message = _("Only one email address allowed.");
index 96cf756..c395468 100644 (file)
@@ -429,11 +429,12 @@ class Horde_Form_Type_EmailConfirm extends Horde_Form_Type {
             $message = _("Email addresses must match.");
             return false;
         } else {
-            require_once 'Horde/MIME.php';
-            $parsed_email = MIME::parseAddressList($value['original'], false,
-                                                   true);
-            if (is_a($parsed_email, 'PEAR_Error')) {
-                $message = $parsed_email->getMessage();
+            try {
+                $parsed_email = Horde_Mime_Address::parseAddressList($value['original'], array(
+                    'validate' => true
+                ));
+            } catch (Horde_Mime_Exception $e) {
+                $message = $e->getMessage();
                 return false;
             }
             if (count($parsed_email) > 1) {
index c4580b2..255cce2 100644 (file)
@@ -99,7 +99,7 @@ class Net_SMS_generic_smtp extends Net_SMS {
     {
         return array(
             'carrier'     => array('label' => _("Carrier"), 'type' => 'text'),
-            'mailBackend' => array('label' => _("PEAR::Mail backend"), 'type' => 'text')
+            'mailBackend' => array('label' => _("Horde_Mail:: backend"), 'type' => 'text')
         );
     }
 
@@ -120,9 +120,7 @@ class Net_SMS_generic_smtp extends Net_SMS {
      */
     function _send($message, $to)
     {
-        require_once 'Mail.php';
-        $m = &Mail::factory($this->_params['mailBackend'],
-                            $this->_params['mailParams']);
+        $m = Horde_Mail::factory($this->_params['mailBackend'], $this->_params['mailParams']);
 
         if (isset($message['carrier'])) {
             $dest = $this->_getDest($to, $message['carrier']);
@@ -130,11 +128,11 @@ class Net_SMS_generic_smtp extends Net_SMS {
             $dest = $this->_getDest($to);
         }
 
-        $res = $m->send($dest, $this->_params['mailHeaders'], $message['text']);
-        if (PEAR::isError($res)) {
-            return array(0, $res->getMessage());
-        } else {
+        try {
+            $m->send($dest, $this->_params['mailHeaders'], $message['text']);
             return array(1, null);
+        } catch (Horde_Mail_Exception $e) {
+            return array(0, $e->getMessage());
         }
     }
 
index a3c28e0..ccd0f83 100644 (file)
@@ -57,12 +57,11 @@ class Net_SMS_vodafoneitaly_smtp extends Net_SMS {
             $headers['From'] = $this->_params['user'];
             $to = $matches[2] . '@sms.vodafone.it';
 
-            $mailer = Mail::factory('mail');
-            $result = $mailer->send($to, $headers, $message['text']);
-            if (is_a($result, 'PEAR_Error')) {
-                return array(0, $result->getMessage());
-            } else {
+            try {
+                Horde_Mail::factory('Mail')->send($to, $headers, $message['text']);
                 return array(1, null);
+            } catch (Horde_Mail_Exception $e) {
+                return array(0, $e->getMessage());
             }
         } else {
             return array(0, _("You need to provide an Italian phone number"));
index c2dd1ab..0ce91b7 100644 (file)
@@ -7,7 +7,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
  <channel>pear.php.net</channel>
  <summary>SMS functionality.</summary>
  <description>This package provides SMS functionality and access to SMS gateways.
-  
  </description>
  <lead>
   <name>Marko Djukic</name>
@@ -74,7 +73,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
    </package>
    <package>
     <name>Mail</name>
-    <channel>pear.php.net</channel>
+    <channel>pear.horde.org</channel>
    </package>
    <package>
     <name>Net_SMPP_Client</name>
index 39f771d..66cde77 100644 (file)
@@ -431,7 +431,7 @@ class Horde_Prefs_Identity
         $body->setContents(Horde_String::wrap($message, 76, "\n"));
         $body->setCharset(Horde_Nls::getCharset());
 
-        $body->send($new_addr, $msg_headers, $GLOBALS['injector']->getInstance('Mail'));
+        $body->send($new_addr, $msg_headers, $GLOBALS['injector']->getInstance('Horde_Mail'));
 
         return new Horde_Notification_Event(sprintf(_("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr));
     }
index ef7f284..bc4d333 100644 (file)
@@ -132,15 +132,10 @@ class Horde_iCalendar_vcard extends Horde_iCalendar {
             return $address;
         }
 
-        static $rfc822;
-        if (is_null($rfc822)) {
-            $rfc822 = new Mail_RFC822();
-        }
-
-        if (!$rfc822->validateMailbox($address)) {
-            return $address;
-        }
-        return Horde_Mime_Address::writeAddress($address->mailbox, $address->host);
+        $rfc822 = new Horde_Mail_Rfc822();
+        return $rfc822->validateMailbox($address)
+            ? Horde_Mime_Address::writeAddress($address->mailbox, $address->host)
+            : $address;
     }
 
 }
index a90070e..edda95d 100644 (file)
@@ -105,6 +105,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <min>1.5.4</min>
    </pearinstaller>
    <package>
+    <name>Mail</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Util</name>
     <channel>pear.horde.org</channel>
    </package>
index ac3f0d2..f23be3a 100644 (file)
@@ -508,8 +508,7 @@ class Horde_Hooks
 //            "\n" .
 //            sprintf(_("You can approve this signup at %s"), Horde::applicationUrl('admin/user.php', true, -1));
 //
-//        $mailer = Mail::factory($GLOBALS['conf']['mailer']['type'], $GLOBALS['conf']['mailer']['params']);
-//        $mailer->send($_SERVER['SERVER_ADMIN'], $headers, $msg);
+//        $GLOBALS['injector']->getInstance('Horde_Mail')->send($_SERVER['SERVER_ADMIN'], $headers, $msg);
 //    }
 //
 //    // Helper function for signup_queued Example #1
index 1ca6fa6..16a952f 100644 (file)
@@ -2,6 +2,7 @@
 v4.0-cvs
 --------
 
+[mms] Remove reliance on PEAR Mail library.
 [jan] Send alarm emails again if the alarm has changed (Bug #8717).
 [mms] Add advanced preferences options screen.
 [mms] Complete rewrite of options UI display.
index 8642d0f..30e57b3 100644 (file)
@@ -86,8 +86,7 @@ below at Prerequisites_.
 
 3. Install PEAR/PECL packages::
 
-     pear install -o Crypt_Blowfish Date DB File Mail Net_DNS \
-                     Services_Weather
+     pear install -o Crypt_Blowfish Date DB File Net_DNS Services_Weather
      pear -d preferred_state=beta install -a HTTP_WebDAV_Server
      pecl install -o fileinfo idn lzf [memcache]
 
@@ -321,12 +320,6 @@ The following prerequisites are **REQUIRED** for Horde to function properly.
 
         pear install Crypt_Blowfish
 
-   b. Mail (>= 1.2.0)
-
-      To install, enter the following at the command prompt::
-
-        pear install Mail
-
    These PEAR modules are **RECOMMENDED** to be installed:
 
    a. Date
index 854e0e5..541da14 100644 (file)
@@ -41,7 +41,6 @@ The following hooks have changed:
 
 Horde_Alarm is using UTC dates now.
 
-Mail 1.2.0 is minimum version.
 Crypt_Blowfish is required.
 
 
index 1e265dc..207c448 100644 (file)
@@ -291,11 +291,6 @@ class Horde_Test
         'HTTP_WebDAV_Server' => array(
             'error' => 'The HTTP_WebDAV_Server is required if you want to use the WebDAV interface of Horde, e.g. to access calendars or tasklists with external clients.'
         ),
-        'Mail' => array(
-            'path' => 'Mail/RFC822.php',
-            'error' => 'You do not have the Mail package installed on your system. See the INSTALL file for instructions on how to install the package.',
-            'required' => true
-        ),
         'MDB2' => array(
             'error' => 'You will need MDB2 if you are using the SQL driver for Shares.',
         ),
index 709d76b..5068914 100644 (file)
@@ -49,7 +49,7 @@ if ((!empty($_SERVER['CONTENT_TYPE']) &&
         } else {
             $params['logger'] = $GLOBALS['injector']->getInstance('Horde_Log_Logger');
         }
-        $mailer = $GLOBALS['injector']->getInstance('Mail');
+        $mailer = $GLOBALS['injector']->getInstance('Horde_Mail');
 
         /* TODO: Probably want to bind a factory to injector for this? */
         $params['registry'] = $GLOBALS['registry'];
index 85f7984..58eacd1 100644 (file)
@@ -112,7 +112,7 @@ case 'send_problem_report':
             }
 
             try {
-                $mail->send($GLOBALS['injector']->getInstance('Mail'));
+                $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
 
                 /* We succeeded. */
                 Horde::logMessage(
index ee12a50..7dac226 100644 (file)
@@ -77,7 +77,7 @@ if ($can_validate && $form->validate($vars)) {
                                           'from' => $email,
                                           'charset' => Horde_Nls::getCharset()));
         try {
-            $mail->send($GLOBALS['injector']->getInstance('Mail'));
+            $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
             $notification->push(_("Your password has been reset, check your email and log in with your new password."), 'horde.success');
             header('Location: ' . Horde::getServiceLink('login')->add('url', $info['url'])->setRaw(true));
             exit;
index d93f690..64e6a23 100644 (file)
@@ -2,6 +2,8 @@
 v5.0-git
 --------
 
+[mms] Pass compose message data to mailer backend via stream; much more
+      efficient, especially with larger messages (Request #8909).
 [mms] Add strip attachments support in DIMP.
 [mms] Add PGP & S/MIME compose support to DIMP.
 [mms] Check for incorrect identity on compose if a single recipient address
index 96998b7..820bd2e 100644 (file)
@@ -95,6 +95,7 @@ class IMP_Application extends Horde_Registry_Application
             'IMP_Identity' => new IMP_Injector_Binder_Identity(),
             'IMP_Imap' => new IMP_Injector_Binder_Imap(),
             'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
+            'IMP_Mail' => new IMP_Injector_Binder_Mail(),
             'IMP_Mailbox' => new IMP_Injector_Binder_Mailbox(),
             'IMP_Quota' => new IMP_Injector_Binder_Quota(),
             'IMP_Search' => new IMP_Injector_Binder_Search(),
index 8777b8e..63fcbea 100644 (file)
@@ -726,10 +726,9 @@ class IMP_Compose
     public function sendMessage($email, $headers, $message)
     {
         $email = $this->_prepSendMessage($email, $headers, $message);
-        $mailer = $this->getMailOb();
 
         try {
-            $message->send($email, $headers, $mailer);
+            $message->send($email, $headers, $GLOBALS['injector']->getInstance('IMP_Mail'));
         } catch (Horde_Mime_Exception $e) {
             throw new IMP_Compose_Exception($e);
         }
@@ -1626,15 +1625,13 @@ class IMP_Compose
 
         $header_text = trim($resent_headers->toString(array('encode' => Horde_Nls::getCharset()))) . "\n" . trim($contents->getHeaderOb(false));
 
-        $mailer = $this->getMailOb(array(
-            'raw' => array('from' => $headers->getValue('from'), 'headertext' => $header_text)
-        ));
-
         $to = $this->_prepSendMessage($recipients);
+        $hdr_array = $headers->toArray(array('charset' => Horde_Nls::getCharset()));
+        $hdr_array['_raw'] = $header_text;
 
         try {
-            Horde_Mime_Mail::sendPearMail($mailer, $to, $headers->toArray(array('charset' => Horde_Nls::getCharset())), $contents->getBody());
-        } catch (Horde_Mime_Exception $e) {
+            $GLOBALS['injector']->getInstance('IMP_Mail')->send($to, $hdr_array, $contents->getBody());
+        } catch (Horde_Mail_Exception $e) {
             throw new IMP_Compose_Exception($e);
         }
 
@@ -2701,62 +2698,6 @@ class IMP_Compose
     /* Static utility functions. */
 
     /**
-     * Return mail driver/params necessary to send a message.
-     *
-     * @return array  'driver' => mail driver; 'params' => list of params.
-     */
-    static public function getMailDriver()
-    {
-        /* We don't actually want to alter the contents of the $conf['mailer']
-         * array, so we make a copy of the current settings. We will apply our
-         * modifications (if any) to the copy, instead. */
-        $params = $GLOBALS['conf']['mailer']['params'];
-
-        /* Force the SMTP host and port value to the current SMTP server if
-         * one has been selected for this connection. */
-        if (!empty($_SESSION['imp']['smtp'])) {
-            $params = array_merge($params, $_SESSION['imp']['smtp']);
-        }
-
-        /* If SMTP authentication has been requested, use either the username
-         * and password provided in the configuration or populate the username
-         * and password fields based on the current values for the user. Note
-         * that we assume that the username and password values from the
-         * current IMAP / POP3 connection are valid for SMTP authentication as
-         * well. */
-        if (!empty($params['auth']) && empty($params['username'])) {
-            $imap_ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
-            $params['username'] = $imap_ob->getParam('username');
-            $params['password'] = $imap_ob->getParam('password');
-        }
-
-        return array(
-            'driver' => $GLOBALS['conf']['mailer']['type'],
-            'params' => $params
-        );
-    }
-
-    /**
-     * Return a Mail object with the current driver parameters.
-     *
-     * @param array $options  Additional options to pass to
-     *                        Horde_Mime_Mail::getMailOb().
-     *
-     * @return Mail  A Mail object.
-     * @throws IMP_Compose_Exception
-     */
-    static public function getMailOb($options = array())
-    {
-        $mail_driver = self::getMailDriver();
-
-        try {
-            return Horde_Mime_Mail::getMailOb($mail_driver['driver'], $mail_driver['params'], $options);
-        } catch (Horde_Mime_Exception $e) {
-            throw new IMP_Compose_Exception($e);
-        }
-    }
-
-    /**
      * Formats the address properly.
      *
      * @param string $addr  The address to format.
diff --git a/imp/lib/Injector/Binder/Mail.php b/imp/lib/Injector/Binder/Mail.php
new file mode 100644 (file)
index 0000000..592f0fd
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Binder for IMP's configuration of Horde_Mail::.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+class IMP_Injector_Binder_Mail implements Horde_Injector_Binder
+{
+    /**
+     */
+    public function create(Horde_Injector $injector)
+    {
+        /* We don't actually want to alter the contents of the $conf['mailer']
+         * array, so we make a copy of the current settings. We will apply our
+         * modifications (if any) to the copy, instead. */
+        $params = $GLOBALS['conf']['mailer']['params'];
+
+        /* Force the SMTP host and port value to the current SMTP server if
+         * one has been selected for this connection. */
+        if (!empty($_SESSION['imp']['smtp'])) {
+            $params = array_merge($params, $_SESSION['imp']['smtp']);
+        }
+
+        /* If SMTP authentication has been requested, use either the username
+         * and password provided in the configuration or populate the username
+         * and password fields based on the current values for the user. Note
+         * that we assume that the username and password values from the
+         * current IMAP / POP3 connection are valid for SMTP authentication as
+         * well. */
+        if (!empty($params['auth']) && empty($params['username'])) {
+            $imap_ob = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
+            $params['username'] = $imap_ob->getParam('username');
+            $params['password'] = $imap_ob->getParam('password');
+        }
+
+        return Horde_Mail::factory($GLOBALS['conf']['mailer']['type'], $params);
+    }
+
+    /**
+     */
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+
+}
index d45172e..ade038c 100644 (file)
@@ -343,8 +343,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
                     // Send the reply.
                     try {
-                        $mailer = IMP_Compose::getMailOb();
-                        $mime->send($organizerEmail, $msg_headers, $mailer);
+                        $mime->send($organizerEmail, $msg_headers, $GLOBALS['injector']->getInstance('IMP_Mail'));
                         $msgs[] = array('success', _("Reply Sent."));
                     } catch (Exception $e) {
                         $msgs[] = array('error', sprintf(_("Error sending reply: %s."), $e->getMessage()));
@@ -444,8 +443,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
                     // Send the reply.
                     try {
-                        $mailer = IMP_Compose::getMailOb();
-                        $mime->send($organizerEmail, $msg_headers, $mailer);
+                        $mime->send($organizerEmail, $msg_headers, $GLOBALS['injector']->getInstance('IMP_Mail'));
                         $msgs[] = array('success', _("Reply Sent."));
                     } catch (Exception $e) {
                         $msgs[] = array('error', sprintf(_("Error sending reply: %s."), $e->getMessage()));
index acb3044..6120f2c 100644 (file)
@@ -117,8 +117,7 @@ class IMP_Ui_Message
 
         /* Send out the MDN now. */
         try {
-            $mailer = IMP_Compose::getMailOb();
-            $mdn->generate(false, $confirmed, 'displayed', $GLOBALS['conf']['server']['name'], $mailer);
+            $mdn->generate(false, $confirmed, 'displayed', $GLOBALS['conf']['server']['name'], $GLOBALS['injector']->getInstance('IMP_Mail'));
             IMP_Maillog::log('mdn', $msg_id, 'displayed');
             $success = true;
 
index 073c4af..3425f0d 100644 (file)
@@ -135,17 +135,17 @@ class Kronolith_FreeBusy
      */
     public static function get($email, $json = false)
     {
-        /* Properly handle RFC822-compliant email addresses. */
-        static $rfc822;
-        if (is_null($rfc822)) {
-            $rfc822 = new Mail_RFC822();
-        }
-
         $default_domain = empty($GLOBALS['conf']['storage']['default_domain']) ? null : $GLOBALS['conf']['storage']['default_domain'];
-        $res = $rfc822->parseAddressList($email, $default_domain);
-        if ($res instanceof PEAR_Error) {
-            throw new Kronolith_Exception($res);
+        $rfc822 = new Horde_Mail_Rfc822();
+
+        try {
+            $res = $rfc822->parseAddressList($email, array(
+                'default_domain' => $default_domain
+            ));
+        } catch (Horde_Mail_Exception $e) {
+            throw new Kronolith_Exception($e);
         }
+
         if (!count($res)) {
             throw new Kronolith_Exception(_("No valid email address found"));
         }
index 28db1df..1417d44 100644 (file)
@@ -1901,24 +1901,30 @@ class Kronolith
             return;
         }
 
-        $parser = new Mail_RFC822;
+        $parser = new Horde_Mail_Rfc822();
         $attendees = array();
+
         foreach (Horde_Mime_Address::explode($newAttendees) as $newAttendee) {
             // Parse the address without validation to see what we can get out
             // of it. We allow email addresses (john@example.com), email
             // address with user information (John Doe <john@example.com>),
             // and plain names (John Doe).
-            $newAttendeeParsed = $parser->parseAddressList($newAttendee, '',
-                                                           false, false);
+            try {
+                $newAttendeeParsed = $parser->parseAddressList($newAttendee, array(
+                    'default_domain' => null,
+                    'nest_groups' => false,
+                    'validate' => false
+                ));
+                $error = (!isset($newAttendeeParsed[0]) || !isset($newAttendeeParsed[0]->mailbox));
+            } catch (Horde_Mail_Exception $e) {
+                $error = true;
+            }
 
             // If we can't even get a mailbox out of the address, then it is
             // likely unuseable. Reject it entirely.
-            if ($newAttendeeParsed instanceof PEAR_Error ||
-                !isset($newAttendeeParsed[0]) ||
-                !isset($newAttendeeParsed[0]->mailbox)) {
+            if ($error) {
                 $notification->push(
-                    sprintf(_("Unable to recognize \"%s\" as an email address."),
-                            $newAttendee),
+                    sprintf(_("Unable to recognize \"%s\" as an email address."), $newAttendee),
                     'horde.error');
                 continue;
             }
@@ -1943,7 +1949,9 @@ class Kronolith
 
                 try {
                     $newAttendeeParsedPartNew = Horde_Mime::encodeAddress(Horde_Mime_Address::writeAddress($newAttendeeParsedPart->mailbox, $newAttendeeParsedPart->host, $name));
-                    $newAttendeeParsedPartValidated = $parser->parseAddressList($newAttendeeParsedPartNew, '', null, true);
+                    $newAttendeeParsedPartValidated = $parser->parseAddressList($newAttendeeParsedPartNew, array(
+                        'default_domain' => null
+                    ));
 
                     $email = $newAttendeeParsedPart->mailbox . '@'
                         . $newAttendeeParsedPart->host;
@@ -2129,7 +2137,7 @@ class Kronolith
             $mail->setBasePart($multipart);
 
             try {
-                $mail->send($GLOBALS['injector']->getInstance('Mail'));
+                $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
                 $notification->push(
                     sprintf(_("The event notification to %s was successfully sent."), $recipient),
                     'horde.success'
@@ -2261,7 +2269,7 @@ class Kronolith
                     $mime_mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion());
                     $mime_mail->setBody($message, Horde_Nls::getCharset(), true);
                     Horde::logMessage(sprintf('Sending event notifications for %s to %s', $event->title, implode(', ', $df_recipients)), 'DEBUG');
-                    $mime_mail->send($GLOBALS['injector']->getInstance('Mail'), false, false);
+                    $mime_mail->send($GLOBALS['injector']->getInstance('Horde_Mail'), false, false);
                 }
             }
         }
index d3f7c6e..d260db5 100755 (executable)
@@ -157,7 +157,7 @@ function send_agendas()
         } catch (Horde_Mime_Exception $e) {}
         Horde::logMessage(sprintf('Sending daily agenda to %s', $email), 'DEBUG');
         try {
-            $mime_mail->send($GLOBALS['injector']->getInstance('Mail'), false, false);
+            $mime_mail->send($GLOBALS['injector']->getInstance('Horde_Mail'), false, false);
         } catch (Horde_Mime_Exception $e) {}
     }
 }
index f13491d..473d323 100644 (file)
@@ -1036,7 +1036,7 @@ class Nag
 
                     Horde::logMessage(sprintf('Sending event notifications for %s to %s',
                                               $task->name, implode(', ', $df_recipients)), 'INFO');
-                    $mail->send($GLOBALS['injector']->getInstance('Mail'));
+                    $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
                 }
             }
         }
index f89486d..19a9eae 100644 (file)
@@ -55,7 +55,7 @@ $body = sprintf(_("%s would you like to invite you to read the news\n Title: %s\
 
 $mail = new Horde_Mime_Mail(array('subject' => $row['title'], 'body' => $body, 'to' => $to, 'from' => $from, 'charset' => Horde_Nls::getCharset()));
 try {
-    $mail->send($GLOBALS['injector']->getInstance('Mail'));
+    $mail->send($injector->getInstance('Horde_Mail'));
     $notification->push(sprintf(_("News succesfully send to %s"), $to), 'horde.success');
 } catch (Horde_Mime_Exception $e) {
     $notification->push($e);
index 1c88379..42e4930 100644 (file)
@@ -54,10 +54,7 @@ function _getBareEmail($address, $allow_multi = false)
         return $address;
     }
 
-    static $rfc822;
-    if (is_null($rfc822)) {
-        $rfc822 = new Mail_RFC822();
-    }
+    $rfc822 = new Horde_Mail_Rfc822();
 
     // Split multiple email addresses
     if ($allow_multi) {
index e4f040e..e00b021 100755 (executable)
@@ -291,11 +291,7 @@ function getBareEmail($address)
         return $address;
     }
 
-    static $rfc822;
-    if (is_null($rfc822)) {
-        $rfc822 = new Mail_RFC822();
-    }
-
+    $rfc822 = new Horde_Mail_Rfc822();
     $rfc822->validateMailbox($address);
     return Horde_Mime_Address::writeAddress($address->mailbox, $address->host);
 }
index b590dc1..9b98270 100644 (file)
@@ -450,8 +450,9 @@ class Whups_Driver {
                 continue;
             }
 
-            $addr_arr = Horde_Mime_Address::parseAddressList($to);
-            if (!is_a($addr_arr, 'PEAR_Error') && isset($addr_arr[0])) {
+            try {
+                $addr_arr = Horde_Mime_Address::parseAddressList($to);
+                if (isset($addr_arr[0])) {
                 $bare_address = strtolower($addr_arr[0]['mailbox'] . '@' . $addr_arr[0]['host']);
                 if (!empty($seen_email_addresses[$bare_address])) {
                     continue;
@@ -461,7 +462,7 @@ class Whups_Driver {
                 if (empty($full_name) && isset($addr_arr[0]['personal'])) {
                     $full_name = $addr_arr[0]['personal'];
                 }
-            }
+            } catch (Horde_Mime_Exception $e) {}
 
             // use email address as fallback
             if (empty($full_name)) {
@@ -489,7 +490,7 @@ class Whups_Driver {
             $mail->addHeader('To', $to, Horde_Nls::getCharset());
 
             try {
-                $mail->send($GLOBALS['injector']->getInstance('Mail'), true);
+                $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'), true);
                 $entry = sprintf('%s Message sent to %s from "%s"',
                                  $_SERVER['REMOTE_ADDR'], $to,
                                  Horde_Auth::getAuth());
index 8c0b865..76972f3 100644 (file)
@@ -187,7 +187,7 @@ class Wicked {
             $mail->addHeader($hkey, $headers[$hkey]);
         }
         try {
-            $mail->send($GLOBALS['injector']->getInstance('Mail'));
+            $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
         } catch (Horde_Mime_Exception $e) {
             $GLOBALS['notification']->push($e);
         }