Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get sendmail working in Alpine Docker container?

I just want to send simple email for testing purposes, but when executing sendmail inside the container, I get sendmail: can't connect to remote host (127.0.0.1): Connection refused. What do I need to take into account when using sendmail inside Alpine container?

like image 553
Kitanotori Avatar asked Aug 04 '17 02:08

Kitanotori


2 Answers

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/

like image 143
John Kawakami Avatar answered Sep 19 '22 18:09

John Kawakami


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.

like image 30
Martin Proulx Avatar answered Sep 18 '22 18:09

Martin Proulx