1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Jobs/Mail/NinjaMailer.php

58 lines
1.4 KiB
PHP
Raw Normal View History

2021-02-14 11:43:44 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-02-14 11:43:44 +01:00
*/
2021-02-14 12:09:32 +01:00
namespace App\Jobs\Mail;
2021-02-14 11:43:44 +01:00
use Illuminate\Mail\Mailable;
class NinjaMailer extends Mailable
{
public $mail_obj;
/**
* Create a new message instance.
*
* @param $mail_obj
*/
public function __construct($mail_obj)
{
$this->mail_obj = $mail_obj;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$from_name = config('mail.from.name');
if(property_exists($this->mail_obj, 'from_name')){
$from_name = $this->mail_obj->from_name;
}
2022-03-04 01:45:19 +01:00
$ninja_mailable = $this->from(config('mail.from.address'), $from_name)
2021-02-14 11:43:44 +01:00
->subject($this->mail_obj->subject)
->view($this->mail_obj->markdown, $this->mail_obj->data)
2021-02-14 11:43:44 +01:00
->withSwiftMessage(function ($message) {
$message->getHeaders()->addTextHeader('Tag', $this->mail_obj->tag);
});
2022-03-04 01:45:19 +01:00
if(property_exists($this->mail_obj, 'text_view')){
$ninja_mailable->text($this->mail_obj->text_view, $this->mail_obj->data);
}
return $ninja_mailable;
2021-02-14 11:43:44 +01:00
}
}