Set up Reply via Email Support ✉


(Jeff Atwood) #1

So you’d like to set up reply via email support for your Discourse forum.

:mega: Reply via email is pre-configured and enabled by default on all discourse.org hosted sites. The guide below only applies to those self-hosting.

Good news! Unlike outgoing email, which is completely unsuitable for typical consumer mail services like GMail, Outlook, Yahoo Mail, etc, incoming reply via-email tends to be extremely low volume. Unless you have a truly massive forum with a zillion people replying to notification emails, you are probably safe using, say, Gmail.

So here’s how to set it up using GMail as an example.

  1. Create a new GMail account. Assign it a username like discourse-replies@example.com or in my case, replies@example.com. Give it a strong password.

  2. Log in to this account via http://mail.google.com. Accept the terms of service, enter the CAPTCHA, load the default web interface. Maybe send a test email, receive a test email. Kick the tires.

  3. POP3s access is off by default in Gmail, so turn it on via Settings, Forwarding and POP/IMAP:

    All incoming emails will be retained by default – but you can tweak as needed.

  4. Visit the Discourse settings and check the Email tab.

  5. Change the following settings:

    • reply_by_email_address enter replies+%{reply_key}@example.com
    • pop3_polling_username enter replies@example.com
    • pop3_polling_password enter the password of that email account
    • pop3_polling_host set to pop.gmail.com
    • pop3_polling_enabled set to true
    • reply_by_email_enabled set to true

There is a certain amount of polling that goes on for this account, but we’ve set it to a low, safe volume – you can configure the polling intervial via the pop3 polling period setting.

We do assume that your email service supports plus addressing aka address tags, so check that before starting. GMail obviously does.

If everything is working, you should see the footer of all notification mails now tell you that you can reply either by visiting the website, or replying via email:

To respond, reply to this email or visit {topic URL} in your browser.

If things aren’t working:

  • check the /logs path on your Discourse in your web browser and look for email related error messages.

  • log into your mail account using your web browser and check for any errors or notifications.

Note: we have seen difficulties when signing up for a GMail account from a different country than your server is located in. For example, if you create the Gmail account from the UK, but the server is in the USA.

Note 2: If you are using a GMail account (e.g. @gmail.com) or a Google Apps mailbox (e.g. a Google mailbox @yourdomain.com), you will need to enable “access from less secure apps” in Google Account settings. If not, you will receive a “POP3 authentication failed” error in Discourse. Access from “less secure apps” is disabled by default.


New: Reply via Email Support!
Email notifications reply directly to me (the admin)
Notification email cannot be the same as reply by email
Questions about using Discourse in a small (<10 people) community
Discourse setting Reply-To value in `From` header field when using reply by eMail feature
Configuring Reply via Email :e-mail:
(Zafarnamah) #2

It would be great to see something similar for Amazon SES. The free tier lets you send 2,000 messages. After that it is ten cents for 1,000 messages. The pricing is here.


(Jeff Atwood) #3

Provided it works like pop3s it will work already, there is nothing else to do. We have discussed IMAP support in the past.


(Helder Ribeiro) #12

Does the reply go to the root topic or as an answer to the specific post you’re replying to?


(Jeff Atwood) #13

It does both of those things – it is posted in the topic as if you had
clicked/tapped the reply button on the thing you are replying to, written a
post, then click/tapped submit.


(Helder Ribeiro) #14

Let me see if I understand. The way I was thinking, I thought each individual post in a thread (topic) had only one parent, and the parent depends on whether I click “Reply” on the post (arrow 1) or “Reply” on the topic (arrow 2):

I imagine clicking Reply #2 makes my post have the first post in the topic as the parent, and clicking Reply #1 sets it to the specific post.

So if the post I’m replying to by email is the last one in the thread, it’s handled as a Reply #2 and if it’s not anymore (there are more recent posts below it), Reply #1? Is that what you mean by “it does both things”?

Or can a post actually have two parents and when I reply by email my post gets both the original post and the replied-to post as parents?

Sorry for the confusion.


(Jeff Atwood) #15

It is more complex than that. If you quote 5 different replies in your reply, it has five “parents” it is attached to as a reply.

Granted, you cannot quote like that in an email reply… but email is, as I said, as if you had clicked/tapped the reply button on the post in the email you are replying to.


(Dan Wilke-Grimm) #29

I may have needed to do some or all of the following to allow Discourse access to POP to my gmail account:

Uncertain about the security implications but want to share.


(Jp Maxwell) #38

Any thoughts about using mail gun? Mailgun will receive incoming e-mail, strip the response thread out and inject the body via an API on the receiving server.

This seems perfect for Discourse allowing users to easily reply and not having a POP box that has to be polled.

Also is there support for starting new threads using e-mail?


(Andrea Bedini) #39

Mailgun also supports POSTing the raw email message to some HTTP endpoint. Supporting this would go around the “vendor specific webhook” @codinghorror frowns upon. I’m looking to see if it’s possible to implement it as a simple plugin. I don’t have much experience with Discourse.


(Andrea Bedini) #40

Yes, see:

https://meta.discourse.org/t/set-up-email-in-start-topic-via-email/27686?source_topic_id=14003

(Tobias Eigen) #47

I think you can future proof this #howto topic by adding “check the mailbox for errors”. The email from Google explains exactly what is needed in this case.


(Dean Taylor) #48

I posted this elsewhere, but thought this might be useful to others here / perhaps edited into the original post.

If you end up with a setup like this after using Gmail for you incoming mailbox …

You can clean up your branding here and stop the user from seeing emails from @gmail.com even when you don’t have mail alias support (username+alias@example.com) with your mail server:

  1. Setup a subdomain reply.my-discourse-site.com
  2. Add additional domain reply.my-discourse-site.com to outgoing mail provider.
  3. Add “TXT” DNS records for SPF / DKIM to reply.my-discourse-site.com provided by your outgoing mail provider.
  4. Setup a mail forwarder to forward *@reply.my-discourse-site.com to my.discourse.site@gmail.com
  5. Change reply to replies+%{reply_key}@reply.my-discourse-site.com

Reply to email - key in subject instead of email address?
Using subject line for reply-by-email identifier
(Tom Newsom) #49

I forwarded your advice to our email guy and he said it wouldn’t work because we already use Google Apps to provide our @domain.com email addresses (and at $6/month we’re not particularly keen on taking on more of them). Is he right?


(Dean Taylor) #50

In this case the sub-domain reply.my-discourse-site.com can use a completely different provider and setup when compared to the domain my-discourse-site.com.
So you “could” use any standard hosting just for MX mail exchange (receipt) on just that sub-domain.

If you are actually paying for “Google Apps for Work” (not the legacy free edition of Google Apps) you can configure mail to forward (to the free Gmail account) for free.

You don’t even need a sub-domain so instead of:
replies+%{reply_key}@reply.my-discourse-site.com
you could go with:
replies+%{reply_key}@my-discourse-site.com

  1. Login as a domain admin https://admin.google.com/
  2. Select “Apps” >“Google Apps” > “Gmail”
  3. Select “Advanced settings >” (near the bottom)
  4. Select “Default routing” at the top
  5. Select “Add Setting”
  6. Setup the setting as follows:

    That regular expression is ^replies\+[^@]+@
    If you have multiple domains in your Google Apps for Work account you might want to include the domain qualifier on the end of that expression (remember to escape you periods \.)
  7. Save

That will then forward that mail elsewhere for free without requiring payment for an additional Google Apps for Work user.


Using subject line for reply-by-email identifier
(Mitchell Krog) #71

Works 100% running it through my postfix server. Thanks for a simple guide to this.


(Geoff Bowers) #74

What is the purpose of the alternative reply by email addresses option?


(Jeff Atwood) #75

No idea! Anyone else know?


(Sam Saffron) #76

I assume this is for added flexibility, but can not thing of the particular use case off the top of my head. For incoming “group” and incoming “category” emails the use case is much easier to explain.


(Jay Pfaffman) #77

You might change the address for some reason and not want the old one(s) to break. The real question is why reply by email address allows just one address and alternative.. allows a list. If reply by email address were a list, there’d be no reason for the other.