public static function sendEmail($to, $from, $subject, $content, $cc = NULL, $bcc = NULL) { $settings = InternSettings::getInstance(); // Sanity checking if (!isset($to) || is_null($to)) { return false; } if (!isset($from) || is_null($from)) { $from = $settings->getSystemName() . ' <' . $settings->getEmailFromAddress() . '>'; } if (!isset($subject) || is_null($subject)) { return false; } if (!isset($content) || is_nulL($content)) { return false; } // Create a Mail object and set it up PHPWS_Core::initCoreClass('Mail.php'); $message = new PHPWS_Mail(); $message->addSendTo($to); $message->setFrom($from); $message->setSubject($subject); $message->setMessageBody($content); if (isset($cc)) { $message->addCarbonCopy($cc); } if (isset($bcc)) { $message->addBlindCopy($bcc); } // Send the message if (EMAIL_TEST_FLAG) { $result = true; } else { $result = $message->send(); } if (PEAR::isError($result)) { PHPWS_Error::log($result); return false; } self::logEmail($message); return true; }
public static function send_email($to, $from, $subject, $content, $cc = NULL, $bcc = NULL) { # Sanity checking if (!isset($to) || is_null($to)) { return false; } if (!isset($from) || is_null($from)) { $from = SYSTEM_NAME . ' <' . FROM_ADDRESS . '>'; } if (!isset($subject) || is_null($subject)) { return false; } if (!isset($content) || is_nulL($content)) { return false; } # Create a Mail object and set it up \PHPWS_Core::initCoreClass('Mail.php'); $message = new PHPWS_Mail(); $message->addSendTo($to); $message->setFrom($from); $message->setSubject($subject); $message->setMessageBody($content); if (isset($cc)) { $message->addCarbonCopy($cc); } if (isset($bcc)) { $message->addBlindCopy($bcc); } # Send the message if (EMAIL_TEST_FLAG) { HMS_Email::log_email($message); $result = true; } else { $result = $message->send(); } if (PEAR::isError($result)) { PHPWS_Error::log($result); return false; } return true; }
/** * Sends email to Wiki Admin if option enabled * * @author Greg Meiste <*****@*****.**> */ function sendEmail() { if (PHPWS_Settings::get('wiki', 'monitor_edits')) { $pagetitle = WikiManager::formatTitle(strip_tags($_REQUEST['page'])); $message = PHPWS_Settings::get('wiki', 'email_text'); $message = str_replace('[page]', $pagetitle, $message); $message = str_replace('[url]', PHPWS_Core::getHomeHttp() . (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $_REQUEST['page'], $message); PHPWS_Core::initCoreClass('Mail.php'); $mail = new PHPWS_Mail(); $mail->addSendTo(PHPWS_Settings::get('wiki', 'admin_email')); $mail->setSubject(sprintf(dgettext('wiki', '%s updated!'), $pagetitle)); $mail->setFrom(PHPWS_User::getUserSetting('site_contact')); $mail->setMessageBody($message); $mail->send(); } }
public static function notifyUser($user, $password) { PHPWS_Core::initCoreClass('Mail.php'); $page_title = Layout::getPageTitle(true); $body[] = sprintf(dgettext('users', '%s created an user account for you.'), $page_title); $body[] = dgettext('users', 'You may log-in using the following information:'); $body[] = sprintf(dgettext('users', 'Site address: %s'), PHPWS_Core::getHomeHttp()); $body[] = sprintf(dgettext('users', 'Username: %s'), $user->username); $body[] = sprintf(dgettext('users', 'Password: %s'), $password); $body[] = dgettext('users', 'Please change your password immediately after logging in.'); $mail = new PHPWS_Mail(); $mail->addSendTo($user->email); $mail->setSubject(sprintf(dgettext('users', '%s account created'), $page_title)); $mail->setFrom(PHPWS_User::getUserSetting('site_contact')); $mail->setReplyTo(PHPWS_User::getUserSetting('site_contact')); $mail->setMessageBody(implode("\n\n", $body)); $result = $mail->send(); return $result; }
/** * Sends everyone (limited by search) in a specific sheet an email */ public function sendEmail() { PHPWS_Core::initCoreClass('Mail.php'); if (!isset($_SESSION['Email_Applicants'])) { $_SESSION['Email_Applicants']['email'] =& $this->email; $_SESSION['Email_Applicants']['sheet_id'] = $this->sheet->id; $_SESSION['Email_Applicants']['search'] = @$_REQUEST['search']; $vars['aop'] = 'send_email'; Layout::metaRoute(PHPWS_Text::linkAddress('signup', $vars, true), 1); $this->title = dgettext('signup', 'Sending emails'); $this->content = dgettext('signup', 'Please wait'); return; } $email_session =& $_SESSION['Email_Applicants']; $mail = new PHPWS_Mail(); $mail->setSubject($email_session['email']['subject']); $mail->setFrom($email_session['email']['from']); $mail->setReplyTo($email_session['email']['from']); $mail->setMessageBody($email_session['email']['message']); $mail->sendIndividually(true); $this->loadSheet($email_session['sheet_id']); if (!$this->sheet->id) { $this->title = dgettext('signup', 'Sorry'); $this->content = dgettext('signup', 'Unable to send emails. Signup sheet does not exist.'); PHPWS_Core::killSession('Email_Applicants'); return; } $db = new PHPWS_DB('signup_peeps'); $db->addColumn('email'); $db->addWhere('sheet_id', $this->sheet->id); if (isset($email_session['search'])) { $search = explode('+', $email_session['search']); foreach ($search as $s) { $db->addWhere('first_name', "%{$s}%", 'like', 'or', 1); $db->addWhere('last_name', "%{$s}%", 'like', 'or', 1); } } $result = $db->select('col'); if (empty($result)) { $this->title = dgettext('signup', 'Emails not sent'); $this->content = dgettext('signup', 'Signup sheet did not contain any applicants.'); return; } elseif (PHPWS_Error::logIfError($result)) { $this->title = dgettext('signup', 'Emails not sent'); $this->content = dgettext('signup', 'An error occurred when pulling applicants.'); return; } foreach ($result as $address) { $mail->addSendTo($address); } $mail->send(); $vars['aop'] = 'report'; $vars['sheet_id'] = $this->sheet->id; $link = PHPWS_Text::linkAddress('signup', $vars, true); $this->title = dgettext('signup', 'Emails sent'); $this->content = dgettext('signup', 'Returning to applicant listing.'); Layout::metaRoute($link, 5); PHPWS_Core::killSession('Email_Applicants'); }
/** * Reports 'this' application to Banner */ public function reportToBanner() { PHPWS_Core::initModClass('hms', 'SOAP.php'); try { $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $soap->createHousingApp($this->getBannerId(), $this->getTerm()); } catch (Exception $e) { // Send an email notification PHPWS_Core::initCoreClass('Mail.php'); $send_to = array(); $send_to[] = '*****@*****.**'; $mail = new PHPWS_Mail(); $mail->addSendTo($send_to); $mail->setFrom(FROM_ADDRESS); $mail->setSubject('HMS Application Error!'); $body = "Username: {$this->getUsername()}\n"; $mail->setMessageBody($body); $mail->send(); throw $e; // rethrow the exception it } // Log the fact that the application was sent to banner PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($this->getUsername(), ACTIVITY_APPLICATION_REPORTED, UserStatus::getUsername()); }