for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Shieldon package.
*
* (c) Terry L. <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Shieldon\Firewall\Firewall\Messenger;
use Shieldon\Messenger\Messenger\MessengerInterface;
use Shieldon\Messenger\Smtp;
use function Shieldon\Firewall\__;
/**
* The get for SMTP.
class ItemSmtp
{
* Initialize and get the instance.
* @param array $setting The configuration of that messanger.
* @return MessengerInterface
public static function get(array $setting): MessengerInterface
$sender = $setting['config']['sender'] ?? '';
$recipients = $setting['config']['recipients'] ?? [];
$host = $setting['config']['host'] ?? '';
$user = $setting['config']['user'] ?? '';
$pass = $setting['config']['pass'] ?? '';
$port = $setting['config']['port'] ?? '';
$instance = new Smtp($user, $pass, $host, (int) $port);
$instance->setSubject(__('core', 'messenger_text_mail_subject'));
$instance->addSender($sender);
foreach ($recipients as $recipient) {
$instance->addRecipient($recipient);
}
return $instance;