/**
 * Send a notification via email using phpmailer
 *
 * @param ElggEntity $from The from user/site/object
 * @param ElggUser $to To which user?
 * @param string $subject The subject of the message.
 * @param string $message The message body
 * @param array $params Optional parameters (not used)
 * @return bool
 */
function phpmailer_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)
{
    global $CONFIG;
    if (!$from) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'from'));
    }
    if (!$to) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'to'));
    }
    if ($to->email == "") {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid));
    }
    $from_email = phpmailer_extract_from_email();
    $site = get_entity($CONFIG->site_guid);
    $from_name = "MetaMorphosis";
    return phpmailer_send($from_email, $from_name, $to->email, '', $subject, $message);
}
Example #2
0
/**
 * Overrides the default email send method of Elgg
 * @note Will need to add code to handle from and to if using: name <email>
 */
function phpmailer_mail_override($hook, $entity_type, $returnvalue, $params)
{
    return phpmailer_send($params["from"], $params["from"], $params["to"], '', $params["subject"], $params["body"]);
}