X-Git-Url: https://git.mxchange.org/?p=quix0rs-gnu-social.git;a=blobdiff_plain;f=lib%2Fmail.php;fp=lib%2Fmail.php;h=2076476f875c54c6171eb05777a4072024f89a88;hp=188792d02a0511fab7493318435a05604a8bb50a;hb=4160a3fb730113f3d712bd777884c4b0482f6df1;hpb=abd90bbdf562614755802885dfb5673645df8575 diff --git a/lib/mail.php b/lib/mail.php index 188792d02a..2076476f87 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -30,9 +30,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } require_once 'Mail.php'; @@ -47,12 +45,14 @@ 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 ServerException($backend->getMessage()); } } return $backend; @@ -69,6 +69,8 @@ function mail_backend() */ function mail_send($recipients, $headers, $body) { + global $_PEAR; + try { // XXX: use Mail_Queue... maybe $backend = mail_backend(); @@ -79,6 +81,9 @@ function mail_send($recipients, $headers, $body) assert($backend); // throws an error if it's bad $sent = $backend->send($recipients, $headers, $body); + if ($_PEAR->isError($sent)) { + throw new ServerException($sent->getMessage()); + } return true; } catch (PEAR_Exception $e) { common_log(