Commit 7b0cdc8
committed
feature symfony#59482 [Mailer] [Smtp] Add DSN option to make SocketStream bind to IPv4 (quilius)
This PR was squashed before being merged into the 7.3 branch.
Discussion
----------
[Mailer] [Smtp] Add DSN option to make SocketStream bind to IPv4
| 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.
Commits
-------
c50235a [Mailer] [Smtp] Add DSN option to make SocketStream bind to IPv4File tree
3 files changed
+18
-0
lines changed- src/Symfony/Component/Mailer
- Tests/Transport/Smtp
- Transport/Smtp
3 files changed
+18
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
183 | 197 | | |
184 | 198 | | |
185 | 199 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
0 commit comments