Help:Toolforge/Email

From Wikitech
Jump to navigation Jump to search

Overview

This page covers using sending email to users, tools, and from the grid.

Mail to users

Mail sent to user@tools.wmflabs.org (where user is a shell account) will be forwarded to the email address that user has set in their Wikitech preferences, if it has been verified (the same as the 'Email this user' function on wikitech).

Any existing .forward in the user's home will be ignored.

Mail to a Tool

Mail can also be sent "to a tool" with:

toolname.anything@tools.wmflabs.org

Where "anything" is an arbitrary alphanumeric string. Mail will be forwarded to the first of:

  • The email addresses listed in the tool's $HOME/.forward.anything, if present;
  • The email addresses listed in the tool's $HOME/.forward, if present; or
  • The email addresses of the tool's maintainers.

Additionally, tools.toolname@tools.wmflabs.org is an alias pointing to toolname.maintainers@tools.wmflabs.org mostly useful for automated email generating from within Cloud VPS.

$HOME/.forward and $HOME/.forward.anything need to be readable by the user Debian-exim; to achieve that, you probably need to explicitly make the file world readable with a shell command like chmod o+r $HOME/.forward*.

Prior to early 2019 it was also possible to use a .forward file to configure automatic processing of in-bound email messages by a grid job. This feature was removed as it was not used by many tools and complicated the maintenance of Toolforge. Similar functionality can be achieved by routing inbound emails to an account on an external mail host with IMAP or POP support and polling for new messages from a cron job or long running process.

Mail from Tools

Sending via SMTP

The SMTP protocol can be used to send outbound emails from a tool running on either Kubernetes or the job grid. The mail.tools.wmflabs.org service name is used as the public mail exchange (MX) host for inbound SMTP messages to the tools.wmflabs.org domain and points to a server that can process both inbound and outbound email for Toolforge.

Containers running on the Toolforge Kubernetes cluster do not install and configure a local mailer service like the exim service that is installed on grid engine nodes. Tools running in Kubernetes should instead send email using an external SMTP server. The mail.tools.wmflabs.org service name should be usable for this. This

Sending via the command line

The job grid hosts in Toolforge install and configure a local mailer service (currently Exim) which can be used to send outgoing email messages. This feature is not available inside Kubernetes containers.

When sending mail from a grid job, the common command line method of piping the message body to /usr/bin/mail may not work correctly because /usr/bin/mail attempts to deliver the message to the local mail submission agent (MSA) in a background process which will be killed if it is still running when the controlling grid job exits.

If piping to a subprocess to send mail is needed, the message including headers may be piped to /usr/sbin/exim -odf -i.

# This does not work when submitted as a job
echo "Test message" | /usr/bin/mail -s "Test message subject" user@example.com

# This does
echo -e "Subject: Test message subject\n\nTest message" | /usr/sbin/exim -odf -i user@example.com
  • Note: /usr/bin/echo supports -e in case your shell's internal echo command doesn't.