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/ValidateMailAddressJob.php

56 lines
2 KiB
PHP
Raw Normal View History

2019-04-24 18:46: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 ValidateMailAddressJob extends Job
{
private $mailObject = null;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Mail $mailObject)
{
$this->mailObject = $mailObject;
}
2019-07-10 15:04:35 +00:00
public $tries = 2;
2019-04-24 18:46:41 +00:00
/**
* 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);
2019-07-10 15:04:35 +00:00
$mail->Subject = Setting::getSettingValue("name_big").Setting::getSettingValue("name_small").' E-Mail validation';
2019-04-24 18:46:41 +00:00
$mail->Body = 'Hello,<br>to validate your E-Mail address click on the following link: <a href="'.Setting::getSettingValue('url').'/gui/mailValidation/'.$this->mailObject->id.'/'.$this->mailObject->validation_code.'">Activate Account</a>';
$mail->AltBody = 'Hello,\r\nto validate your E-Mail address click on the following link: '.Setting::getSettingValue('url').'/gui/mailValidation/'.$this->mailObject->id.'/'.$this->mailObject->validation_code;
$mail->send();
}
}