Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[mailgun-mailer] support EU-endpoint #31897

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

Closed
wants to merge 3 commits into from

Conversation

bullder
Copy link

@bullder bullder commented Jun 6, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets #31810
License MIT
Doc PR

Provide support for regions for mailer-railgun bridge

return self::SMTP_DOMAIN_EU;
}

return self::SMTP_DOMAIN_US;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make sure that the region is always either EU or US? US might be a reasonable default, but silently falling back to US in case we receive garbage does not feel right.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just in case to preserve previous behaviour. Before changes it was used US

Copy link
Member

@derrabus derrabus Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping US as default if no region is set is probably reasonable. But I would expect an error if I set the region to MiddleEarth, Asia, Europe or any string other than EU or US.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it enough to have just error as undefined index during access mapping const? or you're expecting like native exception?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined index will only be a notice in production, and won't fail properly. So please add an exception (which also allows providing a better message in dev mode, so better DX).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I hope RuntimeException will be fine for you

src/Symfony/Component/Mailer/Bridge/Mailgun/Mailgun.php Outdated Show resolved Hide resolved
src/Symfony/Component/Mailer/Bridge/Mailgun/Mailgun.php Outdated Show resolved Hide resolved
Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add test cases for region=US and for omitting the region in the DSN.

*
* @experimental in 4.3
*/
class Mailgun
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we find a more expressive name? MailgunRegions maybe?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me too confused with that naming

@bullder bullder force-pushed the mailgun-mailer-region branch from d5e48b6 to 27ccf5b Compare June 6, 2019 14:40
@bullder
Copy link
Author

bullder commented Jun 6, 2019

We should add test cases for region=US and for omitting the region in the DSN.

done

@bullder bullder force-pushed the mailgun-mailer-region branch from 27ccf5b to 2f93b85 Compare June 6, 2019 15:02
@bullder bullder changed the base branch from 4.3 to master June 6, 2019 16:10
[mailgun-mailer] support EU-endpoint. fix tests

[mailgun-mailer] support EU-endpoint. fix tests without region

[mailgun-mailer] support EU-endpoint. fix notices

[mailgun-mailer] support EU-endpoint. improve test

[mailgun-mailer] support EU-endpoint. Default region in transport declaration
@bullder bullder force-pushed the mailgun-mailer-region branch from 9470747 to 359e214 Compare June 6, 2019 16:11
@nicolas-grekas nicolas-grekas added this to the next milestone Jun 6, 2019
@nicolas-grekas nicolas-grekas changed the base branch from master to 4.4 June 6, 2019 17:40
@bullder
Copy link
Author

bullder commented Jun 6, 2019

I would be glad if someone assist to fix deps builds in travis. I can't figure out how to fix it.

{
$this->key = $key;
$this->domain = $domain;
$this->endpoint = MailgunRegionConfiguration::resolveApiEndpoint($domain, $region);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the MailgunRegionConfiguration class is really needed.

You can, just change the ENDPOINT constant in each Mailgun Transports (or add it for the smtp transport) to add the region endpoint, something like : private const ENDPOINT = 'https://%region_endpoint%.mailgun.net/v3/%domain%/messages'
And store the region the same way as the domain, $this->regionEndpoint = 'us' === $region ? 'api' : 'api.eu';

Then (at line 51) replace the domain and the region endpoint at the same time
$endpoint = str_replace(['%domain%', '%region_endpoint%'], [urlencode($this->domain), $this->regionEndpoint], self::ENDPOINT);

What do you think ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that might be become tricky as soon as new region for example Asia might have host name https://mailgun.asia/

Me too don't like that helper class but we have to resolve endpoint in 3 different transports so sooner or later we have met case at which that will require to be extracted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they would use the same pattern instead of using something different. But anyway, that's speculation at this point. I prefer #31998, which implements it the same as what we have in SesTransport, so it's more consistent across the board.

src/Symfony/Component/Mailer/Transport.php Outdated Show resolved Hide resolved
@bullder bullder force-pushed the mailgun-mailer-region branch from e6c83b8 to 565cfe4 Compare June 7, 2019 09:35
self::REGION_US => 'smtp.mailgun.org',
];

private const ENDPOINT_DOMAINS = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API_HOSTS for consistency with SMTP_HOSTS.

@fabpot
Copy link
Member

fabpot commented Jun 12, 2019

Closing in favor of #31998

@fabpot fabpot closed this Jun 12, 2019
@bullder bullder deleted the mailgun-mailer-region branch June 13, 2019 12:12
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.