Hi there,
I needed to send e-mails in HTML (and not raw) and wanted to use the queue for better scalability. As I saw that there is only a SendRawEmailJob
in flarum/core
I implemented my own Job. Here is the code if someone wants to use it:
use Flarum\Queue\AbstractJob;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Mail\Message;
class SendHtmlEmailJob extends AbstractJob
{
private $email;
private $subject;
private $view;
private $data;
public function __construct(string $email, string $subject, string $view, array $data)
{
$this->email = $email;
$this->subject = $subject;
$this->view = $view;
$this->data = $data;
}
public function handle(Mailer $mailer)
{
$mailer->send($this->view, $this->data, function (Message $message) {
$message->to($this->email);
$message->subject($this->subject);
});
}
}