stricter mailer#667
Open
simonLeary42 wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the mail-sending flow to rely on PHPMailer’s native exception behavior and to avoid cross-message state leakage by constructing a fresh PHPMailer instance per send, which requires template-level subject setting to target the per-message mailer.
Changes:
- Refactors
UnityMailerto no longer extendPHPMailer, and instead create/configure a newPHPMailer(exceptions: true)instance for eachsendMail()call. - Updates Twig mail templates to call
setSubject(mailer, ...)so the rendered template sets the subject on the per-send PHPMailer instance. - Removes the custom
UnityMailerExceptionpathway in favor of PHPMailer exceptions.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/lib/UnityMailer.php | Refactors mailer construction/sending and Twig wiring to support per-message PHPMailer instances and native exceptions. |
| resources/mail/user_sshkey.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/user_loginshell.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/user_flag_removed.html.twig | Updates subject-setting calls in all branches to pass mailer. |
| resources/mail/user_flag_removed_admin.html.twig | Updates subject-setting calls in all branches to pass mailer. |
| resources/mail/user_flag_added.html.twig | Updates subject-setting calls in all branches to pass mailer. |
| resources/mail/user_flag_added_admin.html.twig | Updates subject-setting calls in all branches to pass mailer. |
| resources/mail/user_expiry_idlelock_warning.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/user_expiry_disable_warning_pi.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/user_expiry_disable_warning_non_pi.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/user_expiry_disable_warning_member.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_request.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_request_owner.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_removed.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_removed_owner.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_idlelocked_owner.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_disabled_owner.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_denied.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_denied_owner.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_added.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_user_added_owner.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_request.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_request_cancelled.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_request_admin.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_reenabled.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_join_request_cancelled.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_disabled.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_denied.html.twig | Updates subject-setting call signature to pass mailer. |
| resources/mail/group_created.html.twig | Updates subject-setting call signature to pass mailer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ba8d295 to
d9e0c42
Compare
d9e0c42 to
054ab27
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3048e30 to
9783ac3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the need for
UnityMailerExceptionby allowingPHPMailerto raise its own exceptions (new PHPMailer(exceptions: true)Requires a new
PHPMailerobject to be constructed before sending each message, to prevent messages from polluting each other (PHPMailer/PHPMailer#3319 (comment))Requires a new
Twig\Environmentobject to be constructed before sending each message, because thesetSubjecttwig function is forever bound to onePHPMailerobject