Skip to content
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

Add a mail() hook to NativeMailHandler. #1948

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdwx
Copy link

@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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant