Last active
April 7, 2021 15:57
Create a class to Instantiate a Mail object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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