danil-smirnov / docker-postfix

Postfix Docker image with SMTP authentication, TLS and OpenDKIM support
MIT License
17 stars 3 forks source link

How to get the host's cron to use this? #7

Closed SystemParadox closed 2 years ago

SystemParadox commented 3 years ago

Firstly thanks for this, I found your image super helpful in moving to a dockerised postfix.

I was wondering if you had any ideas for how to get cron on the host machine to use this? I've got ports 25 and 587 mapped to the host, but cron seems to want a sendmail command, which is normally provided by postfix. It seems crazy and potentially very confusing to install postfix on the host machine just to get sendmail, and it's going to conflict with the mapped ports.

I tried minimalist options like msmtp but then I end up with bare or invalid from headers like From: root or From: root (Cron Daemon) and the mail gets rejected.

Do you have any suggestions for how to set this up sanely?

danil-smirnov commented 2 years ago

Hi It seems there is no direct way for cron to leverage docker-postfix container from the host. You need some mediator to pass messages. I usually use ssmtp for this purpose. It seems to provide what you are looking for:

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES