Skip to content

vs-point/symfony-mailjet-mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailjet Mailer

Provides Mailjet integration for Symfony Mailer.

Usage

  1. Installation via composer
composer require vs-point/symfony-mailjet-mailer
  1. Register in services.yaml
VSPoint\Mailjet\Transport\MailjetTransportFactory:
   tags:
      - mailer.transport_factory
  1. Provide configuration in .env file
{JETMAILER_NAME}=mailjet://{public key}:{private key}@api.mailjet.com

Send base email

$dsn = 'mailjet://{public key}:{private key}@api.mailjet.com';

$transport = Transport::fromDsn($dsn);
$mailer = new Mailer($transport);
$email = (new Email())
            ->from('hello@example.com')
            ->to('you@example.com')
            //->cc('cc@example.com')
            //->bcc('bcc@example.com')
            //->replyTo('fabien@example.com')
            //->priority(Email::PRIORITY_HIGH)
            ->subject('Time for Symfony Mailer!')
            ->text('Sending emails is fun again!')
            ->html('<p>See Twig integration for better HTML integration!</p>');
$mailer->send($email);

Send templated email

$dsn = 'mailjet://{public key}:{private key}@api.mailjet.com';

$transport = Transport::fromDsn($dsn);
$mailer = new Mailer($transport);
$email = (new MailjetTemplateEmail(123456789,['variable'=>'value']))
            ->from('my@mail.com');
$mailer->send($email);