$params['password'] = Horde_Auth::getCredential('password');
}
- $result = Mail::factory($driver, $params);
- if ($result instanceof PEAR_Error) {
- throw new Horde_Exception($result);
+ try {
+ return Horde_Mime_Mail::getMailOb($driver, $params);
+ } catch (Horde_Mime_Exception $e) {
+ throw new Horde_Exception($e);
}
-
- return $result;
}
public function equals(Horde_Injector_Binder $binder)
}
/**
+ * 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.
*
--- /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);
+ }
+
+}
<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>
+ <notes>* Add Mail driver extensions (raw header output).
* 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.
<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" />
</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" />