tehplague / swiftmailer-mailgun-bundle

Swiftmailer Mailgun transport as a Symfony bundle
104 stars 49 forks source link

Had to use substantially different config to get this bundle working. #43

Open henrypenny opened 7 years ago

henrypenny commented 7 years ago

Here's the config I needed to get this working:

Using Guzzle5 adaptor.

swiftmailer:
    transport: %mailer_transport%
    spool:     { type: memory }

cspoo_swiftmailer_mailgun:
    key: "%mailer_mailgun_key%"
    domain: "%mailer_mailgun_domain%"

services:
    mailgun.library:
        class: Mailgun\Mailgun
        public: true
        arguments: ["%mailer_mailgun_key%", '@guzzle5.adpater']
        calls:
          - ['setApiVersion', ['v3']]

    guzzle5.adpater:
        class: 'Http\Adapter\Guzzle5\Client'
        arguments: ['@guzzle5.client']

    guzzle5.client:
        class: GuzzleHttp\Client
        arguments: [{'base_url':'https://api.mailgun.net', {'defaults' : {'auth' : ['api', '%mailer_mailgun_key%']}}}]

This is quite different to the docs, so I'm wondering where I went wrong.

Nyholm commented 7 years ago

What version are you running?

You should not be required to configure the guzzle client like that.

henrypenny commented 7 years ago

From composer.lock:


            "name": "cspoo/swiftmailer-mailgun-bundle",
            "version": "0.3.1",
...
            "name": "mailgun/mailgun-php",
            "version": "v2.3.2",
...
            "name": "php-http/guzzle5-adapter",
            "version": "v1.0.0",

I have had swiftmailer-mailgun-bundle working for several years. I recently had to upgrade from symfony 2.7 to 2.8 and that's when everything stopped working.

Previously I had in my lockfile:

            "name": "cspoo/swiftmailer-mailgun-bundle",
            "version": "dev-master",
...
            "name": "mailgun/mailgun-php",
            "version": "v1.8",

No php-http or guzzle adapters.

It definitely didn't work with the setup in your docs. I have no idea if there's something else weird in my codebase though.

I also noticed that different client providers seemed to require different mailer_mailgun_domain formats.

Sometimes:

    mailer_mailgun_domain: 'acme.com'

Sometimes:

    mailer_mailgun_domain: 'https://api.mailgun.com/v3/acme.com'

I'm not sure about that - I'm using the 'acme.com' form right now.

Unfortunately I have no more time to investigate this further, but I'm posting this in the hope it is of some use to you or helps someone else in a bind.