vs-point/symfony-mailjet-mailer

Symfony Mailjet Mailer Bridge

v1.0.4 2020-11-30 16:01 UTC

This package is auto-updated.

Last update: 2024-04-29 04:21:22 UTC


README

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);