[GSoC21 Application Task] Email server app (/apps/email_server) with nullmailer
This is an application task for Google Summer of Code 2021. It has no web UI but provides a set of actions to configure and test the Nullmailer MTA. Installation is required. Its landing page is at http://freedombox.local/plinth/apps/email_server
The action implements three functionalities: --reconfigure
, --diagnose
and --send-test-email-to [addr]
. After installing the app, wait for Plinth to download a few dependencies. Then, run the --reconfigure
option or follow this wiki page to set up your Nullmailer MTA.
$ sudo /freedombox/actions/email_server --reconfigure
-- Information about this server --
Server FQDN: test.localhost
Admin email address: RecipientEmailExample@debian.org
-- Information about your email account --
SMTP server: smtp.debian.org
SSL/TLS port [465]:
Email address [RecipientEmailExample@debian.org]:
Password or access token:
Config updated
Test your configuration by sending an email.
sudo /freedombox/actions/email_server --diagnose
/freedombox/actions/email_server --send-test-email-to RecipientEmailExample@debian.org
Replace RecipientEmailExample@debian.org
with a working email address. You may or may not need root permission to send the email.
Exit codes
The following exit codes are returned by email_server
to indicate failures.
- 1 (EXIT_FAIL) Generic failure
- 10 (EXIT_SYNTAX) Syntax error, invalid input
Python API
import plinth.modules.email_server.actions as esa
esa.send_test_email_to('RecipientEmailExample@debian.org')
send_test_email_to(to_address)
- Send a test email to the specified address. This function requires working Nullmailer configuration. The subject and body of test emails cannot be changed.
-
parameter str
to_address
: email address for test notification -
returns: exit code of
mail
(not the action). Non-zero value indicates failure -
raises
ValueError
: if it encounters an invalid email address -
raises
Exception
: for other errors (such as file access problems)
Troubleshooting
Some providers reject emails that contain unrecognized sender addresses. Put a valid sender address/return path in /etc/nullmailer/adminaddr
. Your test email's From
header will be set to your adminaddr.
Still having trouble? Run sudo service nullmailer status
to check delivery logs.
Limitations
- Only plaintext auth is supported
- TLS must be used
- Cannot have whitespace, quotation marks, backward slashes, control characters or non-ASCII characters in the password
- Similar restrictions apply to the email address
Miscellany
-
In
/etc/nullmailer/remotes
, the syntax for using TLS (instead of STARTTLS opportunistic encryption) is like:smtp.example.com smtp --port=465 --auth-login --ssl --user=you@example.com --pass=Password
-
GMail logs the SMTP client's IP address in the
Received
header for anti-phishing purposes. If you are a GMail user and do not want that, then use a VPN or only send test emails to yourself.