Skip to content

Send the login code as a formatted mail - #20

Merged
JeroenDeDauw merged 1 commit into
masterfrom
format-the-login-code-email
Aug 22, 2026
Merged

Send the login code as a formatted mail#20
JeroenDeDauw merged 1 commit into
masterfrom
format-the-login-code-email

Conversation

@alistair3149

@alistair3149 alistair3149 commented Aug 21, 2026

Copy link
Copy Markdown
Member

The code arrived as five lines of unstyled text, with nothing in it to say which wiki had sent it or
that the eight digits in the middle were the point. It read like something to be deleted unread,
which is a poor start for the one message standing between a member and their account.

Send it as a formatted part with a plain-text alternative: the wiki's name, the code set apart in a
panel of its own, how long it lasts, and what to do if it was not you. The plain part carries the
same code and the same warning rather than a note that the mail is better read elsewhere, since for
many wikis it is the only part that ships.

The formatted part is a Mustache template, so what it looks like is changed by editing markup rather
than by concatenating strings in PHP. It is table layout and inline styles throughout, because a
mail client is not a browser and the classic Outlook still in use across the companies this
extension serves lays out with Word's engine. Every string reaches it already localised, and
Mustache escapes what it interpolates, so a wiki's site name cannot carry markup into the mail.

Nothing in it is fetched from the network. No link, since a login mail that trains its reader to
click one is a phishing template with a head start, and no image, since clients block remote ones by
default and would show a broken box where a logo went.

MediaWiki keeps the formatted part only where $wgAllowHTMLEmail is on, which it is not by default.
That setting governs every mail a wiki sends, so it is recommended in the README rather than set
here, which is what Echo does with it too. Without it the code still arrives, as the plain part
alone.

The code is shown in groups of four so it can be held in the head between the mail and the form.
That is a display alone: a member who copies the spaces along with the digits is no longer refused
their own code.

Considered, omitted:

  • setting $wgAllowHTMLEmail from the extension, which would reformat every mail the wiki sends
  • a logo, which clients block by default and which the wiki's name in type does the job of
  • putting the code in the subject line, which is the biggest convenience in an OTP flow and also
    puts the code on a locked screen — left as it was, and worth deciding on its own

Verified by sending a real code through the dev wiki and reading both parts out of the mailbox,
rather than only in tests.

AI-authored — Claude Code, Opus 5 (1M context); design chosen by @alistair3149 from rendered options, who also settled the $wgAllowHTMLEmail question; diff not yet human-reviewed; PHPCS, PHPStan and 756 tests pass locally, and the delivered mail was rendered and inspected.

@codecov-commenter

codecov-commenter commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.75%. Comparing base (0c08453) to head (65f579b).

Files with missing lines Patch % Lines
src/Application/DisplayedCode.php 66.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #20      +/-   ##
============================================
+ Coverage     86.67%   86.75%   +0.07%     
- Complexity      567      574       +7     
============================================
  Files            63       64       +1     
  Lines          1959     1985      +26     
============================================
+ Hits           1698     1722      +24     
- Misses          261      263       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alistair3149
alistair3149 force-pushed the format-the-login-code-email branch from 4d19a76 to 681378b Compare August 21, 2026 20:31
@alistair3149
alistair3149 changed the base branch from code-screen-address-and-resend to master August 21, 2026 20:31
@alistair3149
alistair3149 force-pushed the format-the-login-code-email branch 4 times, most recently from 0ab1cc6 to b391a50 Compare August 21, 2026 20:51
@alistair3149

alistair3149 commented Aug 21, 2026

Copy link
Copy Markdown
Member Author
HTML Plain text
email-formatted email-plain-text

We could have an option to allow the wiki logo in the email, but that would be a follow-up.

The code arrived as five lines of unstyled text, with nothing in it to say which
wiki had sent it or that the eight digits in the middle were the point. It read
like something to be deleted unread, which is a poor start for the one message
standing between a member and their account.

Send it as a formatted part with a plain-text alternative: the wiki's name, the
code set apart in a panel of its own, how long it lasts, and what to do if it was
not you. The plain part is rewritten to say the same, since a wiki that has not
turned formatted mail on sends only that one.

The formatted part is a Mustache template, so what it looks like is changed by
editing markup rather than by concatenating strings in PHP. What a mail client will
and will not lay out is written down there rather than here.

MediaWiki keeps the formatted part only where $wgAllowHTMLEmail is on, which it is
not by default. That setting governs every mail a wiki sends, so the README says to
set it rather than the extension setting it, which is what Echo does with it too.

The code is shown in groups of four so it can be held in the head between the mail
and the form. That is a display alone: a member who copies the spaces along with
the digits is no longer refused their own code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@alistair3149
alistair3149 force-pushed the format-the-login-code-email branch from b391a50 to 65f579b Compare August 21, 2026 21:03
@alistair3149
alistair3149 marked this pull request as ready for review August 21, 2026 21:08
@JeroenDeDauw
JeroenDeDauw merged commit e56d3bb into master Aug 22, 2026
6 checks passed
@JeroenDeDauw
JeroenDeDauw deleted the format-the-login-code-email branch August 22, 2026 12:41
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.

3 participants