Skip to content

Add multipart login emails with text/plain alternatives#325

Open
Sogl wants to merge 1 commit intogetgrav:developfrom
Sogl:feature/multipart-emails
Open

Add multipart login emails with text/plain alternatives#325
Sogl wants to merge 1 commit intogetgrav:developfrom
Sogl:feature/multipart-emails

Conversation

@Sogl
Copy link
Contributor

@Sogl Sogl commented Feb 25, 2026

Summary

This PR adds proper multipart email support to the Login plugin by sending both HTML and plain-text parts for login-related emails.

Why

Some mail clients and filters handle HTML-only emails poorly. Adding a text/plain alternative improves compatibility, accessibility, and reliability (especially for activation/reset flows where the raw URL is important).

What changed

  1. Updated classes/Email.php:
  • replaced default single-template setup with multipart body assembly;
  • keeps HTML template as primary part;
  • automatically adds a plain-text part if a matching emails/login/<template>.txt.twig exists;
  • added a small templateExists() helper using Twig loader.
  1. Added plain-text templates:
  • templates/emails/login/activate.txt.twig
  • templates/emails/login/reset-password.txt.twig
  • templates/emails/login/welcome.txt.twig
  • templates/emails/login/notification.txt.twig
  • templates/emails/login/invite.txt.twig

Each template reuses existing translation keys/context and includes the direct action link as plain text.

Backward compatibility

  • If no .txt.twig exists for a template, behavior remains HTML-only.
  • Existing HTML templates and email subjects are unchanged.

Notes

This change is intentionally minimal and limited to login email composition/templates only.

@rhukster
Copy link
Member

I'll take a look at this when i circle back to Grav plugins.. probably next week.

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