Skip to content

stricter mailer#667

Open
simonLeary42 wants to merge 6 commits into
mainfrom
stricter-mailer
Open

stricter mailer#667
simonLeary42 wants to merge 6 commits into
mainfrom
stricter-mailer

Conversation

@simonLeary42
Copy link
Copy Markdown
Member

@simonLeary42 simonLeary42 commented Apr 3, 2026

Removes the need for UnityMailerException by allowing PHPMailer to raise its own exceptions (new PHPMailer(exceptions: true)

Requires a new PHPMailer object to be constructed before sending each message, to prevent messages from polluting each other (PHPMailer/PHPMailer#3319 (comment))

Requires a new Twig\Environment object to be constructed before sending each message, because the setSubject twig function is forever bound to one PHPMailer object

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 UnityMailer to no longer extend PHPMailer, and instead create/configure a new PHPMailer(exceptions: true) instance for each sendMail() 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 UnityMailerException pathway 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.

Comment thread resources/lib/UnityMailer.php
Comment thread resources/lib/UnityMailer.php Outdated
Comment thread resources/lib/UnityMailer.php Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread resources/lib/UnityMailer.php Outdated
Comment thread resources/lib/UnityMailer.php
Comment thread resources/lib/UnityMailer.php
@simonLeary42 simonLeary42 marked this pull request as ready for review April 3, 2026 17:16
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.

2 participants