Skip to content

[Mailer] Add compatibility for Mailtrap's sandbox #61315

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

Open
wants to merge 15 commits into
base: 7.4
Choose a base branch
from

Conversation

KiloSierraCharlie
Copy link

Mailtrap's sandbox requires the Inbox ID to be passed as part of the URI, which has previously been neglected.

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues n/a
License MIT

Previously #61305 but I messed up when re-basing to 7.4.

Updates with appropriate tests and changelog.

Mailtrap's sandbox requires the Inbox ID to be passed as part of the URI, which has previously been neglected.
Correct setter function for inbox id within the transport factory test.
Spelling mistake made with changelog for sandbox compatibility.
@KiloSierraCharlie
Copy link
Author

Sorry about that @Chris53897. Mistake resolved with commit.

KiloSierraCharlie and others added 2 commits August 5, 2025 11:02
Swap order of 7.3 and 7.4 within changelog.

Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
Cleaner method of forming URI for sandbox.

Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
@kbond
Copy link
Member

kbond commented Aug 5, 2025

Thanks for working on this @KiloSierraCharlie. There's still some logic needed to change the endpoint host if an inboxId is provided?

Suggested changes made as part of PR symfony#61315.
@KiloSierraCharlie
Copy link
Author

Apoligies @kbond & @nicolas-grekas - new commit e767fd6 with all changes submitted to branch.

Copy link
Member

@kbond kbond left a comment

Choose a reason for hiding this comment

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

I wonder: it isn't super clear that when you have an inboxId, the sandbox is used. Could it lead to some confusion as to why the live isn't being used.

Would it make more sense to have separate DSN schemes for the sandbox?

# SANDBOX SMTP
MAILER_DSN=mailtrap+sandbox+smtp://PASSWORD@default

# SANDBOX API
MAILER_DSN=mailtrap+sandbox+api://INBOX_ID:TOKEN@default

Add a new DSN for Mailtrap's sandbox to support the use of the sandbox service & differentiate from the live environment.
Change security of HEADERS_TO_BYPASS to support the sandbox transport.
@KiloSierraCharlie
Copy link
Author

@kbond Thanks for the suggestion, I think you're right - adding a seperate DSN makes it clearer as to which Mailtrap environment is being used. I've created a new transport which extends the original.

Unit tests for this new DSN added also.

KiloSierraCharlie added a commit to KiloSierraCharlie/symfony-docs that referenced this pull request Aug 5, 2025
Add documentation relating to the Mailtrap sandbox implementation in 7.4 (symfony/symfony#61315).
@KiloSierraCharlie KiloSierraCharlie requested a review from kbond August 5, 2025 19:23
Changes to match the Symfony code style.
Changes to match the Symfony code style.
Changes to match the Symfony code style.
Changes to match the Symfony code style.
Changes to match the Symfony code style.
@KiloSierraCharlie
Copy link
Author

I'll get there eventually 😢

Use separate tests for sandbox and live APIs. Use phpunit attributes as per recent standards.
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy