Files
project/app/TenantMail.php
2025-01-09 11:18:12 +01:00

33 lines
923 B
PHP

<?php
namespace App;
use App\Http\Option;
use Illuminate\Mail\Mailer;
use Illuminate\Support\Facades\Mail;
class TenantMail
{
/**
* Build a tenant-mailer from options
*
* @return Mailer
*/
public static function get(): Mailer
{
$options = Option::optionsAsObject();
$mailer = Mail::build([
'transport' => $options->mail_transport,
'host' => $options->mail_host,
'port' => $options->mail_port,
'encryption' => (property_exists($options, 'mail_encryption')) ? $options->mail_encryption : null,
'username' => (property_exists($options, 'mail_encryption')) ? $options->mail_username : null,
'password' => (property_exists($options, 'mail_encryption')) ? $options->mail_password : null,
]);
$mailer->alwaysFrom($options->email, $options->representative);
return $mailer;
}
}