This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccount/app/Jobs/Mails/RecoverPasswortJob.php

56 lines
2 KiB
PHP
Raw Permalink Normal View History

2019-05-02 10:47:41 +00:00
<?php
namespace App\Jobs\Mails;
use App\Jobs\Job;
use App\Models\Mail;
use App\Models\Setting;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
class RecoverPasswortJob extends Job
{
private $mailObject = null;
private $token = null;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Mail $mailObject, $token)
{
$this->mailObject = $mailObject;
$this->token = $token;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
if(Setting::getSettingValue("smtp_active") == false) {
return;
}
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = Setting::getSettingValue("smtp_host");
$mail->SMTPAuth = Setting::getSettingValue("smtp_smtpAuth");
$mail->Username = Setting::getSettingValue("smtp_username");
$mail->Password = Setting::getSettingValue("smtp_password");
$mail->SMTPSecure = Setting::getSettingValue("smtp_secure");
$mail->Port = Setting::getSettingValue("smtp_port");
$mail->setFrom(Setting::getSettingValue("smtp_from_mail"), Setting::getSettingValue("smtp_from_name"));
$mail->addAddress($this->mailObject->mail);
$bcc = Setting::getSettingValue("smtp_bcc");
if(!empty($bcc)) {
$mail->addBCC($bcc);
}
$mail->isHTML(true);
$mail->Subject = Setting::getSettingValue("name").' Password Recovery';
$mail->Body = 'Hello,<br>to reset your Password click on the following link: <a href="'.Setting::getSettingValue('url').'/gui/passwordReset/'.$this->mailObject->getUser()->id.'/'.$this->token.'">Activate Account</a>';
$mail->AltBody = 'Hello,\r\nto reset your Password click on the following link: '.Setting::getSettingValue('url').'/gui/passwordReset/'.$this->mailObject->getUser()->id.'/'.$this->token;
$mail->send();
}
}