Beispiel #1
1
 static function send_reset_password($email = null)
 {
     if (Adapter::row_count(Adapter::secure_query('SELECT mail FROM users WHERE mail = :mail', [':mail' => $email])) == 1) {
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $system_settings = unserialize(SYSTEM_SETTINGS);
         $mail->Host = $system_settings['smtp_server'];
         $mail->From = 'admin@azure.gs';
         $mail->FromName = $system_settings['hotel_name'];
         $mail->AddAddress($email);
         $mail->IsHTML(true);
         $mail->Subject = 'Reset-Password Confirmation';
         $mail->Body = Page::include_content('reset_password', 'others/mail');
         $get_details = Adapter::fetch_object(Adapter::secure_query('SELECT id,username,mail FROM users WHERE mail = :mail', [':mail' => $email]));
         $mail->Body = str_replace('{{mail_username}}', $get_details->username, $mail->Body);
         $mail->Body = str_replace('{{mail_email}}', $get_details->mail, $mail->Body);
         $hash = md5($get_details->mail . '_' . $get_details->username . '_' . rand(0, 9));
         Adapter::secure_query('INSERT INTO cms_restore_password (user_id,user_hash) VALUES (:userid,:userhash)', [':userid' => $get_details->id, ':userhash' => $hash]);
         $mail->Body = str_replace('{{confirm_url}}', $system_settings['global_url'] . '/reset-password/' . $hash, $mail->Body);
         $mail->Body = str_replace('{{hotel_name}}', $system_settings['hotel_name'], $mail->Body);
         $mail->Send();
         $mail->ClearAllRecipients();
         $mail->ClearAttachments();
     }
 }
Beispiel #2
1
 /**
  *
  * @return PHPMailer
  */
 protected function getMail()
 {
     if (!$this->mail) {
         $this->mail = new PHPMailer();
         if (Options::value('mail_smtp')) {
             $this->mail->IsSMTP();
             $this->mail->SMTPAuth = Options::value('mail_smtp_auth', true);
             $this->mail->AuthType = Options::value('mail_smtp_auth_type', 'LOGIN');
             $this->mail->Host = Options::value('mail_smtp_host');
             $this->mail->Port = Options::value('mail_smtp_port', 465);
             $this->mail->Username = Options::value('mail_smtp_user');
             $this->mail->Password = Options::value('mail_smtp_password');
         }
         $this->mail->From = Options::value('mail_from_email');
         $this->mail->Sender = Options::value('mail_from_email');
         $this->mail->FromName = Options::value('mail_from_name');
         $this->mail->CharSet = 'utf-8';
         $this->mail->Priority = 1;
     }
     return $this->mail;
 }
Beispiel #3
0
 /**
  * Set the SMTP's options for PHPMailer.
  *
  * @param PHPMailer $mail The PHPMailer to setup.
  * @return void
  */
 public function setSmtpOptions(PHPMailer $mail)
 {
     $config = $this->config();
     if (!$config['smtp']) {
         return;
     }
     $this->logger->debug(sprintf('Using SMTP "%s" server to send email', $config['smtp_hostname']));
     $mail->IsSMTP();
     $mail->Host = $config['smtp_hostname'];
     $mail->Port = $config['smtp_port'];
     $mail->SMTPAuth = $config['smtp_auth'];
     $mail->Username = $config['smtp_username'];
     $mail->Password = $config['smtp_password'];
     $mail->SMTPSecure = $config['smtp_security'];
 }