8000 Add a mail() hook to NativeMailHandler. by jdwx · Pull Request #1948 · Seldaek/monolog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a mail() hook to NativeMailHandler. #1948

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
Mar 15, 2025

Conversation

jdwx
Copy link
Contributor
@jdwx jdwx commented Feb 21, 2025

The existing call to the global mail() function in NativeMailHandler::send() is replaced with a call to a protected method NativeMailHandler::mail() that takes the same parameters. The provided implementation of NativeMailHandler::mail() passes through to the global mail() function, leaving existing behavior completely unchanged.

This allows subclassing NativeMailHandler so that the call to mail() can be replaced in cases where additional processing needs to happen.

Tests are mostly updated to use this method to test sent messages, but one test is added to make sure that everything gets passed through intact in the default case.

I have run into a number of cases specific to FreeBSD 14+ where its new native mailer (dma) often rejects messages generated by Monolog. The added functionality makes it much easier to shim in the needed adjustments without having to maintain an entire local copy of NativeMailHandler to alter one line.

This approach would also allow for other more general post-processing of outbound messages if needed.

Thanks!

Allows subclassing NativeMailHandler so that the call to mail()
can be intercepted and replaced in cases where additional processing
needs to happen.

Tests are mostly updated to use this method to test sent messages,
but one test is added to make sure that everything gets passed through
intact.
@Seldaek Seldaek merged commit 9cfd246 into Seldaek:main Mar 15, 2025
16 of 18 checks passed
@Seldaek
Copy link
Owner
Seldaek commented Mar 15, 2025

Makes sense, thanks

@Seldaek Seldaek added this to the 3.x milestone Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0