function contactus_submit(Pieform $form, $values)
{
    global $SESSION;
    $data = new StdClass();
    $data->fromname = $values['name'];
    $data->fromemail = $values['email'];
    $data->subject = $values['subject'];
    $data->message = $values['message'];
    if ($values['userid']) {
        $data->fromuser = $values['userid'];
    }
    // OVERWRITE 1: replacement, changed from:
    //require_once('activity.php');
    //activity_occurred('contactus', $data);
    // changed to:
    global $CFG;
    $contact_email = $CFG->current_app->getPersonObject()->getEmail();
    if ($contact_email == '') {
        $contact_email = $CFG->current_app->getOwnerUser()->getObject()->email;
    }
    $params = array('from_name' => $data->fromname, 'from_email' => $data->fromemail, 'subject' => $data->subject, 'message' => $data->message, 'eschool_full_name' => $CFG->current_app->getFullName(), 'eschool_url' => $CFG->current_app->getUrl());
    $email = new GcrEmailer('contactus', trim($contact_email), 'New ' . $CFG->current_app->getFullName() . ' Message', $params, $data->fromemail);
    $email->sendHtmlEmail();
    // END OVERWRITE 1
    $SESSION->add_ok_msg(get_string('messagesent'));
    redirect();
}
 public function sendHtmlEmail()
 {
     $send_email = false;
     foreach ($this->users as $user) {
         if (!$user->addMessageToInbox($this->subject, $this->body, $this->body, $this->from_user, $this->message_type)) {
             $send_email = true;
         }
     }
     if ($send_email) {
         parent::sendHtmlEmail();
     }
     return true;
 }
 protected function emailNewEschoolGC($eschool, $contact1, $contact2)
 {
     global $CFG;
     $mhr_user_obj = $CFG->current_app->getCurrentUser()->getObject();
     $institution = $eschool->getInstitution();
     $to = array(gcr::gcEschoolNotification);
     //send email to global classroom
     $from = "*****@*****.**";
     //set the headers
     $replyto = "*****@*****.**";
     $params = array('time' => date("D: m/d/Y H:i"), 'user' => $mhr_user_obj->username, 'name' => $mhr_user_obj->firstname . " " . $mhr_user_obj->lastname, 'email' => $mhr_user_obj->email, 'eschool_full_name' => $eschool->getFullName(), 'eschool_url' => $eschool->getAppUrl(), 'institution_full_name' => $institution->getFullName(), 'institution_url' => $institution->getAppUrl(), 'public_contact_phone' => $contact1->getPhone1(), 'public_contact_phone_alt' => $contact1->getPhone2(), 'admin_contact_phone' => $contact2->getPhone1(), 'admin_contact_phone_alt' => $contact2->getPhone2());
     $email = new GcrEmailer('new_eclassroom_gc', $to, 'A New Stratus Catalog Was Successfully Created', $params, $from, $replyto);
     $email->sendHtmlEmail();
 }
 public function emailInfoToGC($params = array())
 {
     $app = $this->getPurchaseTypeApp();
     $user_institution = $this->getPurchaserInstitution();
     $mhr_user = $this->getPurchaserUser();
     $mhr_user_obj = $mhr_user->getObject();
     $params['eschool'] = $app;
     $params['user_eschool'] = $user_institution;
     $params['time'] = "Time " . date("D: m/d/Y H:i");
     $params['user_info'] = "{$mhr_user_obj->username}: {$mhr_user_obj->firstname} {$mhr_user_obj->lastname} ({$mhr_user_obj->email}) @ {$user_institution->getFullName()} ({$user_institution->getShortName()})";
     $params['eschool_info'] = "{$app->getFullName()} ({$app->getShortName()})";
     $params['sales_info'] = "Total: " . GcrPurchaseTable::gc_format_money($this->amount);
     $params['purchase_id'] = $this->id;
     $to = gcr::gcPurchaseNotification;
     $subject = "Purchase ID# " . $this->id;
     $from = "*****@*****.**";
     //set the headers
     $replyto = "*****@*****.**";
     $email = new GcrEmailer('purchase_info', $to, $subject, $params, $from, $replyto);
     $email->sendHtmlEmail();
 }
 protected function emailNewEschoolGC($owner_credentials)
 {
     $person = $this->institution->getPerson2Object();
     $contact_person = $this->institution->getPersonObject();
     $to = array(gcr::gcEschoolNotification);
     //send email to global classroom
     $from = "*****@*****.**";
     //set the headers
     $replyto = "*****@*****.**";
     $params = array('time' => date("D: m/d/Y H:i"), 'user' => $owner_credentials->username, 'name' => $person->getFirstName() . " " . $person->getLastName(), 'email' => $person->getEmail(), 'eschool_full_name' => $this->institution->getFullName(), 'eschool_url' => $this->institution->getAppUrl(), 'default_eschool_url' => $this->institution->getDefaultEschool()->getAppUrl(), 'public_contact_phone' => $contact_person->getPhone1(), 'public_contact_phone_alt' => $contact_person->getPhone2(), 'public_contact_email' => $contact_person->getEmail(), 'admin_contact_phone' => $person->getPhone1(), 'admin_contact_phone_alt' => $person->getPhone2());
     $email = new GcrEmailer('trial_created_gc', $to, 'A New Stratus Platform Was Successfully Created', $params, $from, $replyto);
     $email->sendHtmlEmail();
 }
<?php

require_once '../config.php';
global $CFG;
$courseinfo = array_slice($_POST, 1, 5);
$teacherinfo = array_slice($_POST, 6);
$sql = 'SELECT * FROM ' . $CFG->current_app->getShortName() . '.mdl_enrol WHERE courseid = ? AND enrol = ?';
$mdl_course = $CFG->current_app->gcQuery($sql, array($courseinfo['courseid'], 'globalclassroom'), true);
$emailinvite = $_POST['emailaddress'];
$params = array('fullname' => $courseinfo['fullname'], 'shortname' => $courseinfo['shortname'], 'password' => $courseinfo['password'], 'courseid' => $courseinfo['courseid'], 'numteachers' => $courseinfo['numteachers'], 'password' => $mdl_course->password);
foreach ($teacherinfo as $key => $value) {
    array_push($params, array_shift($teacherinfo));
}
$email = new GcrEmailer('invite_to_course', trim($emailinvite), 'Course Invite', $params, '*****@*****.**');
$email->sendHtmlEmail();