Postfix
Contents
Installation
Most distributions include a postfix package.
The daemon (named master) is started by running:
postfix start
Within a container
The bad news is that the Postfix service is designed to be launched from userspace using postfix(1), rather than being a binary that can be invoked in the foreground. This defies the architecture of modern containers.
The good news is that running Postfix in a standalone container is barely useful. Postfix will likely need to run alongside at least one other service. The solution to both issues is running a supervisor.
Consider the following configuration for Supervisord:
[supervisord] childlogdir=/var/log/supervisord logfile=/dev/stderr logfile_maxbytes=0 nodaemon=true user=root [program:postfix] autostart=false command=postfix start startsecs=0 redirect_stderr=true
Configuration
Administration
Testing the service
Install mailx and send an empty email.
To test mail relay to external hosts, try:
mail -s 'Test Email' '[email protected]' </dev/null
Reviewing the queue
Two useful administrative utilities exist for reviewing the mail queue: postqueue(1) and postcat(1).
To view the mail queue, try:
postqueue -p
This will display the queued messages, the senders and recipients, and a mail ID.
To force all queued mail to be sent now, run:
postqueue -f
To instead force a singular message to be send now, run:
postqueue -i MAILID
To instead inspect a message in the queue, try:
postcat -vq MAILID