-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Sendgrid mailer transport does not respect custom ports #36224
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
Comments
I've created a PR based on the report that adds a unit test that reproduces this issue. (it aims branch 5.0 as that's where the bug was reported but I can backport it if needed) I initially thought we could use the same approach as for the SendgridApiTransport and override the port before returning: symfony/src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridTransportFactory.php Line 32 in f5ff33c
Digging into it I spotted this:
There is a whole validation of What are the thoughts on this? How should I proceed? |
Hey, thanks for your report! |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
I don't understand why this bug still not fixed until now nearly 2 years it was add it here! The same problem i have with gmail (also ignores the port in dsn) and i couldn't use the mailer without the tricky way to change it. |
The answer is as simple as that nobody contributed the needed changes yet. PR welcome |
May I ask why one would need to change the port / tls setting when talking to gmail/sendgrid? Also, this can already be achieved by using a regular smtp dns, eg |
Hi @nicolas-grekas, it does appear that the gmail transport parses things correctly. This is specifically for the sendgrid transport. Here are the docs on which port to use: https://docs.sendgrid.com/for-developers/sending-email/integrating-with-the-smtp-api#smtp-ports. Minimal test case to reproduce:
Output:
Probably just a matter of setting the port here: https://github.com/symfony/sendgrid-mailer/blob/5.4/Transport/SendgridTransportFactory.php#L36-L38. |
for sendgrid, something like this should work: but I'd still like an answer to my previous question: why? |
This does appear to work, still seems like a gap IMO though.
Because this is the port that the doc I linked to recommends?
|
This argument looks very weak to me. If everything works already with the current default, we shouldn't be looking for a problem. I think we should close this issue (and the related PRs) as invalid. |
🤷♂️ . Attempting to deviate from the default here: https://symfony.com/doc/current/mailer.html#using-a-3rd-party-transport will not work as expected. I can't remember exactly why this was the case when I originally opened this issue, but the default was not an option for me at the time. |
Thanks for your understanding.
To anyone that wants us to reconsider closing this issue, please help answer this question first. |
…ailer transport DSN (dreadnip) This PR was submitted for the 6.3 branch but it was merged into the 5.4 branch instead. Discussion ---------- Add note about custom port being ignored by specific mailer transport DSN See symfony/symfony#49768 Seems like there has been some confusion about this: * symfony/symfony#46979 * symfony/symfony#44794 People start with the default they're given by the docs, e.g. `sendgrid+smtp` and then try to append `:<port>` to configure it, which doesn't work. As far as I know, the official recommendation is to use the regular `smtp` transport instead when using custom config: symfony/symfony#36224 (comment) Commits ------- b39027f Add note about custom port configuration being ignored by specific mailer transport DSN
Symfony version(s) affected:
symfony/sendgrid-mailer v5.0.5
Description
The Sendgrid Smtp Transport does not respect custom ports provided in the DSN. From Sendgrid's documentation (https://sendgrid.com/docs/for-developers/sending-email/getting-started-smtp/), they suggest the following:
On inspection, it looks like this is how the various Smtp transports are setup so maybe this is an explicit design decision?
Also, it should be noted that you can get around this via something like:
but this seems like it'd be nice for the library to handle for you since it already handles DSN parsing well.
How to reproduce
Test script
Output:
Possible Solution
Ideally, this should probably be parsed and injected here https://github.com/symfony/sendgrid-mailer/blob/master/Transport/SendgridTransportFactory.php#L36, so that we can pass it down to
EsmtpTransport
which handles the defaults (https://github.com/symfony/mailer/blob/master/Transport/Smtp/EsmtpTransport.php) but that doesn't really leave us with a lovely constructor forSendgridSmtpTransport
.The text was updated successfully, but these errors were encountered: