File: /var/www/vhosts/creativefellows.nl/recht.creativefellows.nl/src/Domain/Mail/FormMailer.php
<?php
namespace App\Domain\Mail;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use Psr\Container\ContainerInterface;
/**
* FormMailer Service
*/
final class FormMailer
{
private $container;
private $mailer;
public function __construct(
ContainerInterface $container,
PHPMailer $mailer
){
$this->container = $container;
$this->mailer = $mailer;
$this->mailer->SMTPDebug = 0;
$this->mailer->isHTML(true);
}
public function body(string $body)
{
$this->mailer->Body = $body;
}
public function subject(string $subject)
{
$this->mailer->Subject = $subject;
}
public function from(array $sender)
{
$this->mailer->setFrom($sender["email"], $sender["name"]);
}
public function to(array $receivers)
{
foreach($receivers as $user)
{
$this->mailer->addAddress($user);
}
}
public function send()
{
return $this->mailer->send();
}
}