'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);
$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 {
//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'));
}
}
$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);
}
}
}
- return $mail->send($GLOBALS['injector']->getInstance('Mail'));
+ return $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
}
/**
continue;
}
$mail->addHeader('To', $to, Horde_Nls::getCharset(), true);
- $mail->send($GLOBALS['injector']->getInstance('Mail'));
+ $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
}
return true;
protected $_identity;
/**
- * A Mail object.
+ * A Horde_Mail_Driver object.
*
- * @var Mail
+ * @var Horde_Mail_Driver
*/
protected $_mail;
* 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)
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'];
</required>
<optional>
<package>
+ <name>Mail</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Mime</name>
<channel>pear.horde.org</channel>
</package>
$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;
}
$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);
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)));
}
}
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;
- }
-}
'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'));
}
}
*/
$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));
}
try {
- return Horde_Mime_Mail::getMailOb($driver, $params);
+ return Horde_Mail::factory($driver, $params);
} catch (Horde_Mime_Exception $e) {
throw new Horde_Exception($e);
}
'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(),
'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()
);
}
$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;
* vCard
* vNote
* vTodo
-
</description>
<lead>
<name>Jan Schneider</name>
<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>
$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) {
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.
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. */
$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() . ')');
- }
-
}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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);
- }
-
-}
* @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')) {
$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);
+ }
}
/**
<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.
<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" />
</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>
</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" />
$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.");
$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) {
{
return array(
'carrier' => array('label' => _("Carrier"), 'type' => 'text'),
- 'mailBackend' => array('label' => _("PEAR::Mail backend"), 'type' => 'text')
+ 'mailBackend' => array('label' => _("Horde_Mail:: backend"), 'type' => 'text')
);
}
*/
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']);
$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());
}
}
$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"));
<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>
</package>
<package>
<name>Mail</name>
- <channel>pear.php.net</channel>
+ <channel>pear.horde.org</channel>
</package>
<package>
<name>Net_SMPP_Client</name>
$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));
}
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;
}
}
<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>
// "\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
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.
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]
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
Horde_Alarm is using UTC dates now.
-Mail 1.2.0 is minimum version.
Crypt_Blowfish is required.
'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.',
),
} 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'];
}
try {
- $mail->send($GLOBALS['injector']->getInstance('Mail'));
+ $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
/* We succeeded. */
Horde::logMessage(
'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;
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
'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(),
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);
}
$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);
}
/* 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.
--- /dev/null
+<?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;
+ }
+
+}
// 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()));
// 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()));
/* 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;
*/
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"));
}
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;
}
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;
$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'
$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);
}
}
}
} 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) {}
}
}
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'));
}
}
}
$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);
return $address;
}
- static $rfc822;
- if (is_null($rfc822)) {
- $rfc822 = new Mail_RFC822();
- }
+ $rfc822 = new Horde_Mail_Rfc822();
// Split multiple email addresses
if ($allow_multi) {
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);
}
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;
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)) {
$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());
$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);
}