Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailgun implementation does not allow changing of base API url #24987

Closed
joebeaver89 opened this issue Jul 27, 2018 · 6 comments
Closed

Mailgun implementation does not allow changing of base API url #24987

joebeaver89 opened this issue Jul 27, 2018 · 6 comments

Comments

@joebeaver89
Copy link

  • Laravel Version: All

Description:

Mailgun have recently added an Europe region which uses separate endpoints to the main global mailgun URL that is currently set in /laravel/framework/src/Illuminate/Mail/Transport/MailgunTransport.php

Having the URL hardcoded like this means that people using the default Mailgun implementation cannot change to the Europe region without a lot more work.

Blog post from Mailgun detailing region introduction: https://www.mailgun.com/blog/we-have-a-new-region-in-europe-yall

New endpoints in Mailgun docs: https://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions

I imagine that ideally the Mailgun API url should be a config item.

@Miguel-Serejo
Copy link

At first I thought this could be solved in the same way as #23910, but the mailgun transport doesn't receive an $options array. The constructor signature would need to be changed, along with a change to the TransportManager to pass the new options in.

These would be breaking changes.

An alternative would be to add a new method to MailgunTransport to force a different base url to be used, but I'm not sure that's a great idea.

@staudenmeir
Copy link
Contributor

I think the first option with the breaking change makes more sense.
Laravel 5.7 should be released in August, so people wouldn't have to wait too long for it.

@mattmcdonald-uk
Copy link
Contributor

mattmcdonald-uk commented Jul 27, 2018

I would have said the issue needed addressing more urgently than that.

The new endpoint from Mailgun is a welcome change for those in the EU wanting to ensure user data doesn't cross outside of the EU (so they don't have to inform and consent users to the fact).

Ideally this would be made available to 5.5 LTS too.

@Miguel-Serejo
Copy link

Knowingly merging breaking changes rarely ends well, especially into an LTS release.

While it isn't an obvious and direct approach, this can currently be made to work by extending the MailServiceProvider, TransportManager, and MailgunTransport classes in your application, and then overriding the ExtendedMailServiceProvider's registerSwiftTransport() method,the ExtendedTransportManager's createMailgunDrvier() method, and the ExtendedMailgunTransport's setDomain() method.

Might be the sort of thing that would make a good laravel-related blog post.

@mattmcdonald-uk
Copy link
Contributor

Great, I've set up a simple package to handle this if anyone else would find it of use.

https://github.com/WildSideUK/Laravel-MailgunEu

@Miguel-Serejo
Copy link

This should still be fixed in the core for 5.7. It doesn't make sense to support custom endpoints for one mail service but require a package for another service.

Thinking about it, it might be worth doing a pass on every service provider to add a way to customize endpoints. Or at least pass in an $options array.

I won't have time to work on this over the weekend, but maybe someone else can take a crack at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants