/** * send an email to one or more recipients * * @param array $recipients array of strings with email addresses of recipients * @param array $headers array mapping strings to strings for email headers * @param string $body body of the email * * @return boolean success flag */ function mail_send($recipients, $headers, $body) { // XXX: use Mail_Queue... maybe $backend = mail_backend(); if (!isset($headers['Content-Type'])) { $headers['Content-Type'] = 'text/plain; charset=UTF-8'; } assert($backend); // throws an error if it's bad $sent = $backend->send($recipients, $headers, $body); if (PEAR::isError($sent)) { common_log(LOG_ERR, 'Email error: ' . $sent->getMessage()); return false; } return true; }
/** * send an email to one or more recipients * * @param array $recipients array of strings with email addresses of recipients * @param array $headers array mapping strings to strings for email headers * @param string $body body of the email * * @return boolean success flag */ function mail_send($recipients, $headers, $body) { try { // XXX: use Mail_Queue... maybe $backend = mail_backend(); if (!isset($headers['Content-Type'])) { $headers['Content-Type'] = 'text/plain; charset=UTF-8'; } 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; } }