65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: marcoglietsch
|
|
* Date: 19.03.19
|
|
* Time: 21:46
|
|
*/
|
|
|
|
namespace App\Jobs;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Contracts\Mail\Mailer;
|
|
|
|
class MailUserMessage implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $template;
|
|
protected $senderMail;
|
|
protected $senderName;
|
|
protected $email;
|
|
protected $title;
|
|
protected $text;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($senderMail, $senderName, $email, $title, $text, $template)
|
|
{
|
|
$this->senderMail = $senderMail;
|
|
$this->senderName = $senderName;
|
|
$this->email = $email;
|
|
$this->title = $title;
|
|
$this->text = $text;
|
|
$this->template = $template;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle(Mailer $mailer)
|
|
{
|
|
$senderMail = $this->senderMail;
|
|
$senderName = $this->senderName;
|
|
$email = $this->email;
|
|
$title = $this->title;
|
|
$text = $this->text;
|
|
$template = $this->template;
|
|
|
|
$mailer->send($template, ['text' => $text], function ($message) use ($senderMail, $senderName, $email, $title)
|
|
{
|
|
$message->to($email)
|
|
->from($senderMail, $senderName)
|
|
->subject($title);
|
|
});
|
|
}
|
|
} |