Linux – “send-mail: Applet not found” when using mail command on alpine linux

alpine-linuxbusyboxemailsendmail

I am using alpine linux running in a docker container to run a webapp. The webapp is supposed to send emails using the mail command from the command line.

To support this, I have installed mail as follows:

apk add mailx

When I try to send a message I get the following error:

bash-4.3# mail foo@bar.com
Subject: test
EOT
Null message body; hope that's ok
bash-4.3# send-mail: applet not found

Not sure what I am doing wrong. Any help is highly appreciated.

Best Answer

There is no default MTA available in Alpine. Besides mailx, you will also need to install and configure a MTA (Mail Transfer Agent), such as postfix:

# apk add postfix
(1/3) Installing db (5.3.28-r0)
(2/3) Installing libsasl (2.1.26-r8)
(3/3) Installing postfix (3.1.3-r0)
Executing postfix-3.1.3-r0.pre-install
Executing busybox-1.25.1-r0.trigger
OK: 8 MiB in 16 packages

Start postfix:

~ # postfix start
postfix/postfix-script: warning: not owned by root: /var/spool/postfix/.
postfix/postfix-script: warning: not owned by root: /var/spool/postfix/pid
postfix/postfix-script: starting the Postfix mail system

Send the test message:

~ # mail -s "Test" test@boo.com
.
EOT
Null message body; hope that's ok
Related Question