0

I am running a php:7.2-apache container and I want to send mails. As ssmtp is retired, I want to use msmtp but I face authentication problems with msmtp.

My goal: Setup msmtp for a docker container such that the container works out of the box (i.e. without me exec into the container and setup some systems)

According to the msmtp man page, msmtp offers several authentication methods and all of them seem to fail for implementing my goal:

  1. keyring with secret-tool: This tool requires an X11 display, so it can't be used in a Dockerfile
  2. encrypted file with gpg: The intialization of gpg and the encryption using gpg requires user interaction and can therefore not be used in a Dockerfile (here, I am not 100% sure)
  3. plain text password: Besides this option being less secure than the others, there is a problem that my mail server rejects authorization from msmtp with this option. My mail server is configured to allow login plain (I tested it with telnet), but somehow msmtp transmits the base64 string "username\0password" instead of "username\0username\0password", which I successfully used in my telnet authentification. I don't know if this is a bug in msmtp, or simply a different protocol or sth. If you know how to change this behavior in msmtp, this would also be awesome!
  4. enter password via command line: This is not what I want, as the server should send mails to a customer on its own.

If anyone has a workaround, or sth I don't see at the moment, I would be very thankful!

PS: It might be of interest that I want to use msmtp to transfer the mail from one docker container to another docker container hosting my mail server. They are in the same docker network, which is not accessible from the outside. Furthermore, the mail server container only listens to the docker bridge and is send-only. If this simplifies things somehow, like "then you don't need the security of authentication and can do xy", I would also be very happy :)

Bluescreen
  • 11
  • 1

1 Answers1

1

I found a solution when looking at the man page again. msmtp offers several different authentication methods in case 3. plain text password. The method login worded for me (in the config file: auth login instead of auth on).

As my connection between the containers is secured with TLS, I am happy with this option. Nevertheless, if you have a better alternative, please let me know!

Bluescreen
  • 11
  • 1