How to get sendmail working in Alpine Docker container? How to get sendmail working in Alpine Docker container? docker docker

How to get sendmail working in Alpine Docker container?


In a container there will be no running MTA (mail transport agent), simply there is no mail server running. For example, you can use ssmtp (https://pkgs.alpinelinux.org/package/edge/main/x86/ssmtp) and configure it to use an outside, for example your providers, smtp-server (eg. mail.yourprovider.com).

Than you can use ssmtp to send email. Here is a similar case where sending mail from inside the php Docker image is not possible. Here you can read further -> https://github.com/docker-library/php/issues/135


If you use the BusyBox sendmail, you can set the configuration in the php.ini file.

BusyBox sendmail relays to an SMTP server. You can specify the server on the command line, with the -S option.

My configuration in php.ini is:

sendmail_path = /usr/sbin/sendmail -S 172.16.239.1 -t -i

I'm using an SMTP server in another container.

https://technote.fyi/code/sysadmin/docker/configuring-alpine-linux-on-docker-to-send-mail-for-wordpress/


Set the SMTPHOST environment variable to the hostname or IP of your smtp server.The code to use this variable exist since since 2008-09-27 in the busybox sendmail commit (https://git.busybox.net/busybox/commit/?id=bed22a01fb19de6e4b4c2c7d8c5953bc7aa2580e) but the usage page was only updated on 2016-07-14 with the commit https://git.busybox.net/busybox/commit/?id=9de7509aa013a8634b13a29008cd58ca971c9c7c. Please note that the online documentation page doesn't reflect these changeshttps://www.busybox.net/downloads/BusyBox.html. Use sendmail --help to see the corrected usage.