* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
require_once 'Mail.php';
function mail_backend()
{
static $backend = null;
+ global $_PEAR;
if (!$backend) {
- $backend = Mail::factory(common_config('mail', 'backend'),
+ $mail = new Mail();
+ $backend = $mail->factory(common_config('mail', 'backend'),
common_config('mail', 'params') ?: array());
- if (PEAR::isError($backend)) {
- common_server_error($backend->getMessage(), 500);
+ if ($_PEAR->isError($backend)) {
+ throw new EmailException($backend->getMessage(), $backend->getCode());
}
}
return $backend;
*/
function mail_send($recipients, $headers, $body)
{
+ global $_PEAR;
+
try {
// XXX: use Mail_Queue... maybe
$backend = mail_backend();
assert($backend); // throws an error if it's bad
$sent = $backend->send($recipients, $headers, $body);
+ if ($_PEAR->isError($sent)) {
+ throw new EmailException($sent->getMessage(), $sent->getCode());
+ }
return true;
} catch (PEAR_Exception $e) {
common_log(