How to send email from docker container to host postfix with bsd-mailx?

1.6k Views Asked by At

I have a running postfix mailserver on my ubuntu host. I might lateron replace it also with a docker container, but for migration, I want to stick with the host postfix first.

How can I send emails from a docker container to the host postfix, if I want to minimize image size?

I tried installing bsd-mailx inside the container, as is has a small package size.

In general, I could now send emails with: echo "test header" | mail -s "test body" [email protected]

But how can I tell command in the docker container to actually send the mail to the host system? Or would I have to mount/bind something from the hosts' postfix into the container? So that mailx sends the mail to the mount?

1

There are 1 best solutions below

3
On BEST ANSWER

mail/mailx both invoke a binary called sendmail. That means that you need to install an MTA which is offering that particular interface.

  • postfix
  • exim
  • maybe nullmailer