Configuring Reply via Email ✉


(Régis Hanol) #1

If your Discourse does not have incoming email set up, here’s how:

:bell: if you already have basic reply via email set up (which is common on hosting plans), and you want to add the ability to start a new topic via email, see this topic.

You have two options for enabling incoming emails to your Discourse: polling via POP3 or pushing to the API

1. Polling emails via POP3

If you want to poll emails using POP3 you must first setup email polling. For that, I recommend that you follow the tutorial @codinghorror wrote about how to setup reply via email.

Since Discourse only supports polling from one POP3 account, you will have to setup forwarding rules between your accounts to make sure all the emails end up in the account you are polling emails from. Discourse is clever enough to deliver the emails to the appropriate destination.

Let’s say that you are polling emails from the “reply@your.domain” account and you want to setup incoming emails for “help@your.domain” and “dev@your.domain”.

You will need to forward all the emails sent to “help@your.domain” and “dev@your.domain” to “reply@your.domain”. If you are using GMail, they have a great tutorial on how to automatically forward incoming emails to another account.

Then, Discourse will periodically poll emails from the “reply@discourse.org” account and deliver the emails to the corresponding category, group, topic or message.

:bell: If you don’t have a SMTP server, you can set one up using our direct-delivery incoming mail Docker image.

2. Pushing emails via the Discourse API

Alternatively, you can push emails to Discourse via the API. For that, you will need

  • To check the manual_polling_enabled site setting.
  • A master API key or an API key associated to a staff member.

Then, to push an email to Discourse, you need to pass the raw email content as the “email” parameter when POSTing to “/admin/email/handle_mail”. The endpoint accepts application/json (recommended), multipart/form-data, or application/x-www-urlencoded request bodies (with an appropriate request Content-Type header, naturally).

You’re done :tada:

Logging and Errors

All incoming emails are logged and are visible in your admin panel at /admin/email/received. You can filter the list using the From, To and Subject field of the emails.

The rejected list (/admin/email/rejected) is much more useful when it comes to understand things. You can filter the list using the From, To and Subject field of the emails as well as the Error message.

At any time, you can click the Error message and a modal will show up with more details. If it’s a known error, you will find a small description explaining why that email was rejected. Then you will find all the headers of the email, the subject and the first 100 words of the raw version of the body. Finally, you will find the rejection email that was sent back to the user.

Among all the known errors, two are more common:

  • reply_user_not_matching_error: a reply came in from a different email address the notification was sent to.

This happens when someone uses more than one email addresses (using email aliases for example) but only reply using one email address. Let’s say that the user registered an account with foo+discourse@bar.com.

  • auto_generated_email_error: happens when at least one of the following criteria is matched
    • the ‘precedence’ header is set to: list, junk, bulk or auto_reply
    • the email is from mailer-daemon, postmaster or noreply
    • any of the headers contain: auto-submitted, auto-replied, auto-reply or auto-generated (non exhaustive list).

Since there is no standard to identify automatic emails we have to use regular expressions to match the most commonly used words and headers. These errors are usually safe to ignore but if you find a genuine email that was mis-classified, then be sure to report it here.

Here are the other known errors you might encounter:

  • empty_email_error: the raw mail we received was blank.
  • user_not_found_error: when staged users is disabled and the sender is not an existing user.
  • no_body_detected_error: we couldn’t extract a body and there was no attachments.
  • inactive_user_error: the sender is not active.
  • silenced_user_error: the sender has been silenced.
  • bad_destination_address: none of the email addresses in the To, Cc and Bcc fields matched a configured incoming email address.
  • strangers_not_allowed_error: a user tried to create a new topic in a category they’re not a member of.
  • insufficient_trust_level_error: a user tried to create a new topic in a category they don’t have the required trust level for.
  • topic_not_found_error: a reply came in but the related topic has been deleted.
  • topic_closed_error: a reply came in but the related topic has been closed.

Known issues


Start a New Topic via Email :e-mail:
Straightforward direct-delivery incoming mail
Does 'reply via email' increase engagement?
"Custom incoming email address" for Groups
MOSS Roadmap - Mailing lists
Is there a way to process previously rejected incoming mail?
Ability to merge users
Reply to staged user goes to Hotmail Junk folder
Incoming email topics/replies can not be processed with user accounts that are less than the approve unless trust level
Google "no-reply" user pending approval
Discourse as a private email support portal
How %{reply_key} create?
Can I start a new topic by sending an email message?
Can I start a new topic by sending an email message?
Connecting telegram bot to discourse
White-listing for incoming group email - "Auto-Submitted: auto-generated"
Creating a read-only mailing list mirror
Plugin to send 'private' SMS or Instant Messages from Categories
Code for receiving emails via Discourse API
Trying to set up reply by email: ActionController::RoutingError (No route matches [POST] "/admin/email/handle_mail")
Discourse vs Email & Mailing lists
Start a New Topic via Email :e-mail:
Staged users can't reply to their own topics
Mail address per category
Transition from Listserv (lsoft) to Discourse
Setting an incoming e-mail address for the staff group
One of my users just group messaged 100 other user with a spam offer
Feature question: Can discourse be configured to send responses as email
Post messages from a Telegram group to a discourse category
Tips for setting up e-mail to my domain?
Create staged user when email is forwarded
1 to 1 PM vs Group Messaging
(Dean Taylor) #2

Checking the code you need to pass the raw email content as the “email” parameter when POSTing.


(Nick) #5

How does the post by email feature play along with the queued posts? I.e. if I have the approve post count or approve unless trust level set to non-zero, will the incoming email handling respect these settings and add the posts to the queue for approval?


#6

@downey is your category a sub-category? Does it have Everyone in the credentials? Trying to figure out where it can fail before looking at the code.


(Régis Hanol) #8

Of course. The posts go through the same workflow as any other posts (only the method of input changes) :wink:


(Jeff Atwood) #11

2 posts were split to a new topic: Can incoming Discourse email support replace old ticket portals?


(Nukeador) #13

I have an issue getting the auto_generated_email_error

Our usercase is that we want to migrate old team emails to groups inside discourse, so the idea was to remove everyone from the team email alias, and just add ourforum@email.address as the only alias recipient (as we have done for some category emails in the past).

Unfortunately discourse rejects these emails:

Your email was marked as “auto generated”, which means it was
automatically created by a computer instead of being typed by a human;
we can’t accept those kinds of emails. If you believe this is an error,
contact a staff member.


(Régis Hanol) #14

Have you tried disabling the “block auto generated emails” site setting?