Skip to content

Instantly share code, notes, and snippets.

@JesseSumrak
Last active April 7, 2021 15:57
Create a class to Instantiate a Mail object
php
<?php
declare(strict_types=1);
namespace App\Mailer;
use Psr\Container\ContainerInterface;
use SendGrid\Mail\Mail;
class SendGridMailMessageFactory
{
public function __invoke(ContainerInterface $container): Mail
{
$config = $container->get('config')['mail'];
$mail = new Mail();
$mail->setFrom(
$config['from']['address'],
$config['from']['name']
);
$mail->setReplyTo(
$config['replyTo']['address'],
$config['replyTo']['name']
);
return $mail;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment