Better error handling when the email subsystem isn't working. The

installer was dying trying to send a confirmation email to the initial
user.
This commit is contained in:
Zach Copley 2011-09-15 16:52:23 -07:00
parent 0bd26ed3f0
commit dcbf2f6871

View File

@ -71,18 +71,25 @@ function mail_backend()
*/ */
function mail_send($recipients, $headers, $body) function mail_send($recipients, $headers, $body)
{ {
// XXX: use Mail_Queue... maybe try {
$backend = mail_backend(); // XXX: use Mail_Queue... maybe
if (!isset($headers['Content-Type'])) { $backend = mail_backend();
$headers['Content-Type'] = 'text/plain; charset=UTF-8';
} if (!isset($headers['Content-Type'])) {
assert($backend); // throws an error if it's bad $headers['Content-Type'] = 'text/plain; charset=UTF-8';
$sent = $backend->send($recipients, $headers, $body); }
if (PEAR::isError($sent)) {
common_log(LOG_ERR, 'Email error: ' . $sent->getMessage()); assert($backend); // throws an error if it's bad
$sent = $backend->send($recipients, $headers, $body);
return true;
} catch (PEAR_Exception $e) {
common_log(
LOG_ERR,
"Unable to send email - '{$e->getMessage()}'. "
. 'Is your mail subsystem set up correctly?'
);
return false; return false;
} }
return true;
} }
/** /**