Skip to content

Proposal: shared email_greeting()/email_footer() helpers for consistent plain-text emails #7314

Description

@FraSanga

Summary

Stock html/inc/email.inc and the various send_*_email() functions across the codebase have no
shared header/footer, and the result is inconsistent from one email to the next. Some examples from
the current code:

  • send_auth_email() ends with a "For further information and assistance with PROJECT, visit ..."
    block.
  • send_thread_notification_email()/send_forum_notification_email() end with a different
    "--------------------------\nTo change email preferences, visit:\n...\nDo not reply to this
    message." block.
  • send_moderation_email(), send_thread_moderation_email(), send_banish_email(),
    send_banish_vote_email() have no footer at all — the message just stops.
  • None of them open with any kind of greeting.

On our own project (Camicia) we put together a small shared pair of helpers to fix this:

function email_greeting($user) {
    return "Hi $user->name,\n";
}

function email_footer($prefs_link = true) {
    $footer = "\n--\n".PROJECT."\n".secure_url_base()."\n";
    if ($prefs_link) {
        $footer .= "\nTo change your email preferences, visit:\n"
            .secure_url_base()."edit_forum_preferences_form.php"
            ."\nDo not reply to this message.\n";
    }
    return $footer;
}

email_greeting() for the opening line (only used for emails going to a real named recipient, not
role-addressed ones like POST_REPORT_EMAILS), and email_footer($prefs_link) for the closing
block — $prefs_link gated because emails to project/team admins aren't gated by their forum
notification preferences, so it doesn't make sense to point them at that page.

Applied across email.inc, forum_email.inc, friend.inc, pm.inc, uotd.inc, ops/notify.php,
ops/manage_user.php, ops/team_import.php, and user/team_founder_transfer_action.php — every
send_*_email() we could find. Along the way this also surfaced two real bugs already reported/fixed
separately (#7311/#7312, and a dead-code duplicate $subject assignment in
send_thread_moderation_email()).

Question for maintainers

Is this worth contributing back, and if so, at what scope? A few things in what we did are more a
matter of taste than a fix, and we'd rather ask first than send a big diff that assumes the answer:

  1. The helpers + consistent usage (the part above) seems like a plain improvement regardless of
    project — happy to open a PR for just this if it's wanted.
  2. We also changed subject lines from "[PROJECT] x" to "PROJECT: x" for consistency — purely
    cosmetic, easy to drop if you'd rather keep the brackets.
  3. For emails that currently go to both a named user and an admin/moderator list with the same
    body (e.g. send_banish_email(), send_moderation_email()), we split them into a personal
    greeting+footer version for the user and a separate third-person version for admins. This is more
    than styling — it changes what admins actually see — so it may be worth its own separate
    discussion regardless of whether 1) is wanted.

Happy to open PR(s) for whichever of these make sense, scoped however's easiest to review.


Drafted with AI assistance (Claude, Anthropic) per the project's AI Assistants Usage Policy.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

  • Status
    Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions