Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vs-point/symfony-mailjet-mailer

Provides Mailjet integration for Symfony Mailer
https://github.com/vs-point/symfony-mailjet-mailer

email mailer mailjet php symfony symfony-component

Last synced: 15 days ago
JSON representation

Provides Mailjet integration for Symfony Mailer

Awesome Lists containing this project

README

        

Mailjet Mailer
==============

Provides Mailjet integration for Symfony Mailer.

## Usage

1. Installation via composer
```bash
composer require vs-point/symfony-mailjet-mailer
```

2. Register in services.yaml

```yaml
VSPoint\Mailjet\Transport\MailjetTransportFactory:
tags:
- mailer.transport_factory
```

3. Provide configuration in .env file
```
{JETMAILER_NAME}=mailjet://{public key}:{private key}@api.mailjet.com
```

### Send base email
```php
$dsn = 'mailjet://{public key}:{private key}@api.mailjet.com';

$transport = Transport::fromDsn($dsn);
$mailer = new Mailer($transport);
$email = (new Email())
->from('[email protected]')
->to('[email protected]')
//->cc('[email protected]')
//->bcc('[email protected]')
//->replyTo('[email protected]')
//->priority(Email::PRIORITY_HIGH)
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!')
->html('

See Twig integration for better HTML integration!

');
$mailer->send($email);
```

### Send templated email
```php
$dsn = 'mailjet://{public key}:{private key}@api.mailjet.com';

$transport = Transport::fromDsn($dsn);
$mailer = new Mailer($transport);
$email = (new MailjetTemplateEmail(123456789,['variable'=>'value']))
->from('[email protected]');
$mailer->send($email);
```