Skip to content

Navigation Menu

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

[Mailer] [Smtp] Add DSN option to make SocketStream bind to IPv4 #59482

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

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

quilius
Copy link
Contributor

@quilius quilius commented Jan 11, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues see below
License MIT

We are sending emails through a Microsoft connector, which verifies the sending server's IP address and sender email address. We started getting these error messages recently:

Symfony\Component\Messenger\Exception\HandlerFailedException(code: 450):
Handling "\Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage" failed:
Expected response code "250" but got code "450", with message
"450 4.7.26 Service does not accept messages sent over IPv6"

Apparently, our server started to connect using IPv6 and the connector only accepts IPv4 addresses. With this PR, we can force the SocketStream to connect to the smtp server via IPv4, by supplying an option in the DSN. Example usage:

MAILER_DSN=smtp://<mydomain>.mail.protection.outlook.com:25?force_ipv4=true

This is my first PR to Symfony, so I tried doing my best to follow the guide.

From the errors I received, I think with DKIM signing IPv6 should be allowed as well. However, I do not have access the DNS records and needed a quick fix. This PR is based on a patch I did in my own project. Probably I will implement an available Microsoft Graph Transport in the future. But perhaps it's worth to keep this option available as well.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@quilius quilius force-pushed the feature/bindToIpv4 branch from 100d478 to a848d95 Compare January 14, 2025 21:57
@@ -6,6 +6,7 @@ CHANGELOG

* Add DSN param `retry_period` to override default email transport retry period
* Add `Dsn::getBooleanOption()`
* Add DSN param `source_ip` to allow binding to a specific IPv4 or IPv6 address. If you want to bind IPv4 without specifying an address, use `0.0.0.0`.
Copy link
Member

Choose a reason for hiding this comment

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

The second sentence does not belong to the changelog but to the documentation IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I have created a PR for the documentation: symfony/symfony-docs#20581

@quilius quilius force-pushed the feature/bindToIpv4 branch from a848d95 to 93652bc Compare January 17, 2025 14:22
@fabpot fabpot force-pushed the feature/bindToIpv4 branch from a8fc5a6 to c50235a Compare January 18, 2025 09:23
@fabpot
Copy link
Member

fabpot commented Jan 18, 2025

Thank you @quilius.

@fabpot fabpot merged commit 7b0cdc8 into symfony:7.3 Jan 18, 2025
10 checks passed
@fabpot fabpot mentioned this pull request May 2, 2025
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.

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