discourse/mail-receiver

Name: mail-receiver

Owner: Discourse

Description: null

Created: 2018-03-26 15:19:27.0

Updated: 2018-03-26 15:19:45.0

Pushed: 2018-03-26 15:19:43.0

Homepage: null

Size: 20

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This container does the job of receiving an e-mail for a specified domain and spawning an instance of another container to do “something” with the e-mail. That's it. All very simple and straightforward. You would think…

Installation and Configuration

Minimal configuration requires you to specify the domain you're receiving mail for, and how to connect to your Discourse instance (URL, API key, etc). This involves setting the following environment variables:

For a straightforward setup, the above environment variables should be enough to get you up and running. If you have a desire for a more complicated setup, the following subsections may provide you with the power you need.

Customised Postfix configuration

You can setup any Postfix configuration variables you need by setting env vars of the form POSTCONF_<var> with the value of the variable you want. For example, if you wanted to add a pre-delivery milter, you might use:

-e POSTCONF_smtpd_milters=192.0.2.42:12345
Syslog integration

Postfix loves to log everything to syslog. In fact, that's really all it supports. Since, by default, Docker is not known for its superlative out-of-the-box syslog integration, this container runs a tiny script which reads all syslog data and dumps it to the container's stderr (which is then examinable by docker logs).

If, by some chance, you have a system which can inject itself into a container and process syslog entries intelligently (such as, say, syslogstash), you can set the SYSLOG_SOCKET environment variable to an alternate path, and the /dev/log syslog socket will be symlinked to that alternate path.

Theory of Operation

Every e-mail that is received is delivered to a custom discourse service. That service, which is a small Ruby program, makes a POST request to the admin interface on the specified URL (DISCOURSE_BASE_URL), with the key and username specified. Discourse itself stands ready to receive that e-mail and process it into the discussion, in exactly the same way as an e-mail received via POP3 polling.

Before delivery to the discourse service, a Postfix policy handler runs, asks Discourse if either the sender and/or recipient are invalid, and if so, rejects the incoming mail during the SMTP transaction, to prevent Discourse later sending out reply emails due to incoming spam (“backscatter”). Legitimate users will be notified of the failure by their MTA, and obvious spam just gets dropped without reply. This step is just about being a good citizen of the Internet and not full spam filtering.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.