Skip to content

Commit

Permalink
Added Symfony 4 setup (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
fluchi authored and Nyholm committed Dec 17, 2018
1 parent e17f277 commit e54da0c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


# Swiftmailer Mailgun bundle

[![Latest Stable Version](https://poser.pugx.org/cspoo/swiftmailer-mailgun-bundle/v/stable)](https://packagist.org/packages/cspoo/swiftmailer-mailgun-bundle)
Expand All @@ -19,6 +20,10 @@ composer require cspoo/swiftmailer-mailgun-bundle php-http/guzzle5-adapter

*Note: You can use any of [these adapters](https://packagist.org/providers/php-http/client-implementation)*

## Configuration

### Symfony 3.4

Also add to your AppKernel:

```php
Expand All @@ -44,6 +49,50 @@ swiftmailer:
Note that the swiftmailer configuration is the same as the standard one - you just
change the mailer_transport parameter.

### Symfony 4.1

Add your Mailgun credentials
```bash
# both .env and .env.dist files
MAILGUN_DOMAIN=<your domain>
MAILGUN_API_KEY=<your key>
MAILGUN_SENDER=<your sender>
```

Adding to you bundle
```php
// config/bundles.php
return [
...
cspoo\Swiftmailer\MailgunBundle\cspooSwiftmailerMailgunBundle::class => ['all' => true],
];
```

Configure your Mailgun credentials:

```yaml
// config/packages/mailgun.yaml
cspoo_swiftmailer_mailgun:
key: '%env(MAILGUN_API_KEY)%'
domain: "%env(MAILGUN_DOMAIN)%"

services:
Mailgun\Mailgun:
class: Mailgun\Mailgun
factory: ['Mailgun\Mailgun', create]
arguments: ['%env(MAILGUN_API_KEY)%']
```

Finally, add the following line on swiftmailer config:
```yaml
// config/packages/swiftmailer.yaml
swiftmailer:
# url: '%env(MAILER_URL)%'
transport: 'mailgun'
spool: { type: 'memory' }
```
Note: Not sure if url line should be commented.

## Usage

First craft a message:
Expand All @@ -68,6 +117,11 @@ Then send it as you normally would with the `mailer` service. Your configuration
$this->container->get('mailer')->send($message);
```

You can also test through terminal using:
```bash
bin/console swiftmailer:email:send --from=<from email> --to=<to email> --subject="Foo" --body="Bar"
```

## Choose HTTP client

Mailgun 2.0 is no longer coupled to Guzzle5. Thanks to [Httplug](http://docs.php-http.org/en/latest/index.html) you can now use any
Expand Down

0 comments on commit e54da0c

Please sign in to comment.