How to setup email for Discourse Forum with Google Apps SMTP-relay right way?

Last updated
App Shah
Crunchify » Technology & Tools » How to setup email for Discourse Forum with Google Apps SMTP-relay right way?
Gmail SMTP Relay Service with Discourse Forum Setup Steps

Sometime back we announce a new forum software for Crunchify readers and for our client. It’s now open for all developers and bloggers if they want to get instant answers for any query they may have. I personally very fond of high knowledge rich forum.

Please visit https://ask.crunchify.com to get started. You do have options to login using Facebook, Twitter, Github or Gmail ID.

As you know Discourse is very popular forum software among all latest tech companies, we thought of giving a try. Also, it’s open source.

Another must related read:

Discourse forum basic setup went perfectly fine. It was simple. I used Linode as our hosting service provider for our client. Linode comes with special Ubuntu 14.04 LTS image which was straight forward.

Once you install and setup Discourse on Linode, it’s very important to have email service setup correctly. To be honest, it took me long time to figure out how to setup Google App’s SMTP relay correct way in setting file discourse.conf.

In this tutorial we will go over detailed steps on how to setup email service correct way if you are google App users.

If you have any of below questions also then you are at right place.

  • Troubleshooting email on a new Discourse install
  • How do I change my SMTP settings (Discourse Docker Install)
  • Emails with local SMTP
  • How to edit e-mail settings for Discourse?
  • How To Install Discourse on Ubuntu 14.04
  • Can’t send mail with gmail SMTP server (in discourse)
  • How to setup Google App SMTP relay service?

Step-1

Login to Google Admin Console

Step-2

  1. Go to Apps
  2. Google Apps
  3. Setting for Gmail
  4. Advance Settings
  5. Search with text relay
Setup-SMTP-Relay-Service-for-Google-App-Gmail - Crunchify Tips

Step-3

  1. Mouse hover and click on configure
  2. Provide all details as you see in below image
    • Select Only addresses in my domains
    • Click check box for Only accept mail from the specified IP address
    • Provide your droplet/host IP address
    • Click check box for Required TLS encryption
  3. Click on Save button to save settings
SMTP-Relay-Service-Settings-for-Discourse-Forum

Step-4

  1. Login to your host/droplet
  2. Open discourse.conf file
  3. Add below settings for email service
    • NOTE: keep username and password field empty
  DISCOURSE_DEVELOPER_EMAILS: 'contact@crunchify.com'

  ## TODO: The domain name this Discourse instance will respond to
  DISCOURSE_HOSTNAME: 'ask.crunchify.com'

  ## TODO: The mailserver this Discourse instance will use
  DISCOURSE_SMTP_ADDRESS: smtp-relay.gmail.com      
  DISCOURSE_SMTP_PORT: 587                        
  DISCOURSE_SMTP_USER_NAME:    
  DISCOURSE_SMTP_PASSWORD:     
  #DISCOURSE_SMTP_ENABLE_START_TLS: true

Step-5

Save your setting and initialize restart of your discourse application. Your email service should be configured correct way now.

Once logged in to your server follow below steps:

$ cd /var/discourse
$ vi containers/app.yml
$ git pull
$ ./launcher rebuild app

Enjoy and happy blogging.

19 thoughts on “How to setup email for Discourse Forum with Google Apps SMTP-relay right way?”

  1. Hello, i have same configuration since 6 month on abuseat . org
    because in mail header i have Received: from localhost.localdomain 🙁

    you have the same problem:

    X-Feedback-Id: 57a92c710e6fc42e8ff5b0e8:mailgun
    Sender: noreply@ask.crunchify.com
    X-Mailgun-Sid: WyJiZGI1MyIsICJob3RmaXJlbmV0QGdtYWlsLmNvbSIsICI3ZTQ0NCJd
    Received: from localhost.localdomain (li976-213.members.linode.com [45.33.22.213])

    Thanks

    Reply
      • i have the same header result:

        X-Feedback-Id: 57a92c710e6fc42e8ff5b0e8:mailgun
        Sender: noreply@ask.crunchify.com
        X-Mailgun-Sending-Ip: 209.61.151.224
        X-Mailgun-Sid: WyJiZGI1MyIsICJob3RmaXJlbmV0QGdtYWlsLmNvbSIsICI3ZTQ0NCJd
        Received: from localhost.localdomain (li976-213.members.linode.com [45.33.22.213])
        by mxa.mailgun.org with ESMTP id 57c93c41.7f98440b2a70-in2;
        Fri, 02 Sep 2016 08:45:53 -0000 (UTC)
        Date: Fri, 02 Sep 2016 08:45:52 +0000
        From: noreply@ask.crunchify.com
        Reply-To: noreply@ask.crunchify.com

        Reply
        • That’s right. I also noticed the same. I tried adding 3rd line below to /etc/hosts file but still i’m getting localhost in email.

          127.0.0.1       localhost
          127.0.1.1       ubuntu
          45.33.22.213    crunchify

          I’ll dig more and update if I find solution.

          Reply
      • Just going through hoops of learning about linux/nginx admin & discourse setup. Thanks for the guide. Why did you move to mailgun in the end, problems with smtp-relay.gmail.com? I had tried with authentication setup but not working so will try without as you suggest, but just wondering if I shouldn’t go for a dedicated smtp service provider instead. Thanks!

        Reply
        • Hi Pete – there isn’t any problem setting up Discourse with Google SMTP-relay. Just because of daily email limitation I moved to mailgun. It seems a registered G Suite user can’t relay more than 10,000 messages in a 24-hour period.

          Reply

Leave a Comment