/** * This functions performs the email notifications * * @param array $users * @return boolean */ protected function notifyByEmail($users) { $userlist = array(); // build mail object with some default values $mail = psm_build_mail(); $mail->Subject = utf8_decode(psm_parse_msg($this->status_new, 'email_subject', $this->server)); $mail->Priority = 1; $body = psm_parse_msg($this->status_new, 'email_body', $this->server); $mail->Body = utf8_decode($body); $mail->AltBody = str_replace('<br/>', "\n", $body); // go through empl foreach ($users as $user) { // we sent a seperate email to every single user. $userlist[] = $user['user_id']; $mail->AddAddress($user['email'], $user['name']); $mail->Send(); $mail->ClearAddresses(); } if (psm_get_conf('log_email')) { // save to log psm_add_log($this->server_id, 'email', $body, implode(',', $userlist)); } }
/** * Execute email test * * @todo move test to separate class */ protected function testEmail() { $mail = psm_build_mail(); $message = psm_get_lang('config', 'test_message'); $mail->Subject = psm_get_lang('config', 'test_subject'); $mail->Priority = 1; $mail->Body = $message; $mail->AltBody = str_replace('<br/>', "\n", $message); $user = $this->getUser()->getUser(); $mail->AddAddress($user->email, $user->name); if ($mail->Send()) { $this->addMessage(psm_get_lang('config', 'email_sent'), 'success'); } else { $this->addMessage(psm_get_lang('config', 'email_error') . ': ' . $mail->ErrorInfo, 'error'); } }
/** * Sends the password-reset-email. * @param int $user_id * @param string $user_email * @param string $user_password_reset_hash */ protected function sendPasswordForgotMail($user_id, $user_email, $user_password_reset_hash) { $mail = psm_build_mail(); $mail->Subject = psm_get_lang('login', 'password_reset_email_subject'); $url = psm_build_url(array('action' => 'reset', 'user_id' => $user_id, 'token' => $user_password_reset_hash), true, false); $body = psm_get_lang('login', 'password_reset_email_body'); $body = str_replace('%link%', $url, $body); $mail->Body = $body; $mail->AltBody = str_replace('<br/>', "\n", $body); $mail->AddAddress($user_email); $mail->Send(); }