Score:0

I'm dockerizing my website setup. What is the best approach to send mails by PHP-FPM in a container?

hu flag

So i've seen a couple of questions about setting up notifications for PHP-based websites, so i'd like to ask you for the best approach. For that,

I have:

  • a WordPress website with custom PHP packages hosted locally, no containers,
  • working sendmail setup being used by PHP working as a smart host, we use a Mailgun account and send mails generated by WordPress to their SMTP,

I want:

  • the same WordPress website I host locally but in Docker,
  • emails are being sent in the same way as it was locally set,
  • I want to avoid hosting anything outside Docker (except nginx).

Options I've seen are:

  • hosting postfix locally (as it can listen on public port and docker0) and using SMTP client on the website container sending mails to a local postfix instance, then postfix instance sending emails to Mailgun SMTP,
  • the same option as above but with hosting postfix on Docker,
  • using just a small client on the website container and that's all what's needed (although no idea if that would work since I have no good experience in setting up mail servers).

Extra questions which would let me understand the problem better:

  • since I want to avoid hosting anything locally, the best approach would be if I hosted Postfix on Docker container, then some small SMTP client like msmtp on the website container so I can replace sendmail being used as a default way to send mails. Do I have to expose port 25 outside the Docker network or having the port exposed within the network is enough?
  • can I just use a small SMTP client like msmtp on the website container and that would be enough? if not, why?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.