Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
848 views
in Plugins by
retagged by
Is there a function that could be called from a plugin to easily send an email to the administrator? In order to report error conditions that need attention but are not suitable for notifying to the user.

2 Answers

0 votes
by
by
Thanks, that’s good start. But it leaves me needing the details for admin.
0 votes
by

In case anyone looks at this for an answer, the function qa_send_email is fine, but I finished up writing a method of my own to send specifically to admins and super admins:

    private function alertAdmins ($message) {
        require_once QA_INCLUDE_DIR . 'app/emails.php';
        $spec = array(
            'columns' => array('email','handle'), 
            'source' => "^users WHERE level >= #",
            'arguments' => array(QA_USER_LEVEL_ADMIN),
        );
        $admins = qa_db_single_select($spec);
        if ($admins) {
            foreach ($admins as $admin) {
                $edata = array(
                    'fromemail' => $admin['email'],
                    'fromname' => $admin['handle'],
                    'toemail' => $admin['email'],
                    'toname' => $admin['handle'],
                    'subject' => qa_lang_html('hubuco_email_filter/admin_error_subject'),
                    'body' => $message,
                    'html' => false
                );
                qa_send_email($edata);
            }
        }
    }
 

...