Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+7 votes
871 views
in Q2A Core by

I've got Q2A running in a Docker container on an AWS EC2 instance. What additional work needs to be done past a base install in order to send mail to users? For example, if I want users to confirm their email before being able to make posts. I do not need the site to receive any emails, just the ability to send (please correct me if this is not the case)

I know there is an Emails section of the Admin page, but I feel like I am missing some SMTP server installation or something, as none of my changes on that page seem to make a difference.

When I send a test message to myself from Admin/Mailing, the page simply states "A server error occurred - please try again."

 Do I need to install an SMTP server on my AWS instance to handle outgoing mail? Am I missing some part of the installation?

UPDATE: The container in which Q2A was hosted did not have the `sendmail` program installed. After installing, I no longer get the aforementioned "A server error has occurred," however now the page just hangs when I click "Send test to me." After a while, it claims to have sent a test message to my email, but I receive no email in any folders. 

Still not sure what to do here...

by
This has nothing to do with Q2A but there should be a port mapping between the send mail ports on the container and the host machine so that mails can go out.
https://stackoverflow.com/questions/26215021/configure-sendmail-inside-a-docker-container
by
Hi. I attempted mapping/exposing/publishing ports 25 and 587 in various combinations on the docker container. Nothing seems to permit mail to be sent. What exactly did you mean by this?

Also, as this does deal with Q2A's installation/setup, I feel it was worth asking on this forum. If there is another place I should be inquiring, please direct me there.

1 Answer

+2 votes
by

You don't need to expose ports on the container for sending mail. However, because the container is most likely on an isolated network on the host system you need something to relay mail through. The top answer to the Stack Overflow question @GateOverflow linked to uses an MTA (Mail Transfer Agent, vulgo mail server) on the host for that purpose.

Since your Q2A instance seems to be configured for using local mail (checkbox "Send email via SMTP instead of local mail" under Admin → Emails left unchecked, which is the default setting) you also need some kind of null mailer inside the container. The top answer to the Stack Overflow question uses SSMTP for that purpose, but other software can be used as well, for example nullmailer or even a full MTA like Postfix with a null client configuration.

The mail flow then goes from Q2A to the null mailer and from there to the host MTA, which will (attempt to) deliver the mail to the recipient's mail server(s).

Note that the host MTA may need to be set up to relay through another MTA if your hosting provider is blocking outbound connections to port 25 (many providers do this for spam prevention).

For further troubleshooting please check e-mail-related logs of both container and host.

...