Set up Reply via Email Support ✉

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.

:bell: Alternately, if you aren’t comfortable using GMail for this, you can set up your own incoming email service using Straightforward direct-delivery incoming mail

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.

63 Likes

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.

http://blog.mailgun.com/open-sourcing-our-email-signature-parsing-library/

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?

1 Like

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.

2 Likes

Yes, see:

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

4 Likes

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
10 Likes

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?

1 Like

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.

9 Likes

No, I think you still want two separate settings. The reply by email address is the template that will be used to generate the return address on outgoing mail, and alternative reply by email addresses is for any other addresses you want recognised as reply addresses for incoming e-mail. As @pfaffman said, you use the alternatives list when you change addresses for some reason, and don’t want new replies people make just after the switch (which will go to the old address, the one that was in the mail they received) to be thrown out.

8 Likes

Can you provide some examples? I am not quite following this

(emphasis added) Doh! So that’s why there are two. :slight_smile:

Fooled you, @zogstrip!

I used to get mail sent to someaddress@oldforum.com. Now I want to use anotheraddress@newforum.com. I don’t messages sent in reply to those old emails with the old address to bounce or otherwise not work.

3 Likes

Oh my… :blush:

Hopefully @mpalmer is here to save us all! :heart_eyes:

Maybe we should change the name of that setting so that it’s not confusing?

2 Likes

I recently had a mail change.

Does that mean i have to:

  • update that field with the old address template
  • forward all mail from the old account to the new account so it gets polled

Problem I have is forwarding email from the old account gets rejected once it passes through the new account with:

Something has gone wrong. Perhaps this topic was closed or deleted while you were looking at it?

An excerpt of the headers on the rejected email include:

From: Lucee Lang <lucee.lang.discourse@gmail.com>
To: hello@lucee.org
Message-ID: <CANfgq1VLZfK5P+hx7=LS3UJfY5QEkmY4v7ttZ4-cgJThYBHJAA@mail.gmail.com>
In-Reply-To: <CAOnx9sCiAX6W6OAgyL-LTcDpAryS_6JR1ipBBPM=5MBB0zBbvw@mail.gmail.com>
References: <topic/401@lang.lucee.org>
 <topic/401/1678@lang.lucee.org>
 <topic/401/1680@lang.lucee.org>
 <CAOnx9sCiAX6W6OAgyL-LTcDpAryS_6JR1ipBBPM=5MBB0zBbvw@mail.gmail.com>
Subject: Fwd: [lucee-lang] LAS Board: 2017 Week 08 Minutes

Where the following changes were made:

Has the change in domain for the forum basically kaiboshed the effort to change the email account?

Raghav, I’m seeing the same issue. I’ve got a dedicated SMTP server setup to send outgoing email but it isn’t doing a DKIM sign on the emails and after tracking it down it seems that discourse is doing exactly what you mentioned, it’s setting the reply-to address (in this case the gmail plus address) in the from header causing the server to skip the DKIM signature which is then causing it to get flagged as spam.

When analyzing the eMail I get the following from a server for a SPF failure:

Sender is not authorized by default to use ‘my.discussion+verp-53aaf8307a0067b9fe202ceee1166fc5@gmail.com’ in ‘mfrom’ identity

Did you figure out how to solve it or why it’s happening?

@Json_Blob can you elaborate what the issue was and how you fixed it?

1 Like

I am getting the same issue:

Sender is not authorized by default to use ‘community+verp-53aaf8307a0067b9fe202ceee1166fc5@youngfoodies.co.uk’ in ‘mfrom’ identity

I have tried using a generic @gmail.com address and a gsuit address that is tied to the same domain that discourse is running on (community.youngfoodies.co.uk)

Mail-tester flags this as spam and a percentage of our forum members also receive it in the spam.

Whats the best way to ensure discourse emails are not flagged as spam when using the verp reply to email address?

Many Thanks

1 Like

As a note, if you have two factor authentication enabled, you can generate an App password for discourse and use it in the Discourse pop3 email password setting without having to enable the Access from less secure apps option in GMail.

5 Likes

Has anything happened in this regard?
@JpMaxMan and @andreabedini have u tried to use mailgun somehow?

1 Like

I tried to set this up with a contact form on our website sending the email. It sets the “reply-to email address” to whatever people fill in on the form, and the “from name” is also set to the name field on the form. But the “from address” is our site’s email address.

The problem is that the site looks at the from address instead of the reply-to address, so all form submissions end up getting assigned to one staging account, even though they have different names and reply to addresses, because they have the same from address.

Is there any way to set this up so that a form submission turned into an email could create accounts correctly? I’m afraid if I set the “from address” to the address submitted in the form that the email will get blocked.