Google G Suite Relay SMTP not working

Hello, I’m trying to install discourse for the first time on a DigitalOcean Linux VPS. This VPS is running multiple sites on Nginx and I followed the tutorial on how to install discourse on multiple sites here: Running other websites on the same machine as Discourse - #182 by angus

Discourse installed and ran fine. But when I make an admin account I never receive an email. I followed this tutorial: crunchify[dot]com/how-to-setup-email-for-discourse-forum-with-google-apps-smtp-relay-right-way/

My server uses postfix to relay emails to Google G Suite and works fine with WordPress and MyBB. Though, the tutorial above does not mention postfix and I assume it directly connects to Google G Suite.

I followed this guide on how to troubleshoot email problems: meta.discourse[dot]org/t/troubleshooting-email-on-a-new-discourse-install/16326

I can telnet to the smtp relay:

$ sudo telnet smtp-relay.gmail.com 587
Trying 2607:f8b0:400d:c04::1c...
Connected to smtp-relay.gmail.com.
Escape character is '^]'.
220 smtp-relay.gmail.com ESMTP n18sm708840ooi.26 - gsmtp

The production log says:

Rendering layouts/email_template.html.erb
  Rendered layouts/email_template.html.erb (Duration: 0.1ms | Allocations: 32)
Delivered mail cf23dab4-3e43-421e-8e54-228489c58874@forums.neuronootropic.org (610.1ms)
Job exception: end of file reached

  Rendering layouts/email_template.html.erb
  Rendered layouts/email_template.html.erb (Duration: 0.2ms | Allocations: 32)
Delivered mail a092f703-b590-4792-bd73-d9e4700c3e3c@forums.neuronootropic.org (261.1ms)
Job exception: end of file reached

I tried setting the email in the app.yml configuration file to noreply@forums.neuronootropic.org because I know that email works, but it’s the same thing. It still sends emails with those numbers, I assume it’s some kind of encryption? They never arrive in my inbox.


My other issue is with nginx. It was working fine just yesterday but today I messed around with the app.yml configuration file and set the URL to be a subdirectory instead of a subdomain.

I just wanted to see if maybe the subdomain is causing the issue with the email not working because my current forum, MyBB, runs in a subdirectory and has no issues with email.

Doing this seems to have broken nginx. For whatever reason, nginx now attempts to load an SSL certificate from the discourse directory even though it’s not specified in my nginx configuration file. Here’s the error:

$ sudo nginx -t
nginx: [emerg] BIO_new_file("/var/discourse/shared/standalone/ssl/ssl.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/var/discourse/shared/standalone/ssl/ssl.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed

I’m using Let’s Encrypt for the SSL certificate and it’s working fine. Nginx had no issues yesterday prior to me trying to run discourse in a subdirectory instead of a subdomain.

Any help would be appreciated.

1 Like

I haven’t actually configured G-Suite Relay for email but it seems as if you need forum.neuronootropic.org to be added and verified as a sending domain in your G-Suite admin account. if that’s the case, given the google documentation, there is no reason for it no not work.

However, if you have neuronootr0pic.org verified at G-Suite you could use something like noreply_forum@neuronootropic.org to send email.

2 Likes

Thanks for the suggestion.

I went back and tested the email. Turns out it can only receive but not send from the address noreply@forums.neuronootropic.org. I set it up as a separate domain in G Suite and thought that the MX records for the main domain would be sufficient for both.

This was not the case. I added MX records for forums.neuronootropic.org and now I can send and receive emails.

However, discourse still does not send an activation email upon admin registration.

Any ideas?

Also, I’m not sure why nginx is trying to load an SSL certificate from the discourse directory when I never specified it to. Any ideas on how to approach this problem?

Edit: I changed the setting notification email to send emails from the main domain instead of the subdomain. Rebuilt discourse and it’s still sending emails from the subdomain.

exec: rails r "SiteSetting.notification_email='noreply@neuronootropic.org'"

$ tail shared/standalone/log/rails/production.log
  Parameters: {"authenticity_token"=>"K6dxoAPvh8PEU6mLHjyFRhY/CcZFFIalhrX08AIh9EgGuOHrJos7i1w0dgdS7okeoSBTrmWJSsc77YpfTnMO4A=="}
  Rendering finish_installation/resend_email.html.erb within layouts/finish_installation
  Rendered finish_installation/resend_email.html.erb within layouts/finish_installation (Duration: 0.4ms | Allocations: 110)
  Rendered layouts/_head.html.erb (Duration: 0.4ms | Allocations: 145)
Completed 200 OK in 19ms (Views: 7.8ms | ActiveRecord: 0.0ms | Allocations: 3036)
  Rendering layouts/email_template.html.erb
  Rendered layouts/email_template.html.erb (Duration: 0.1ms | Allocations: 32)
Delivered mail bce41ef8-2288-42cd-b7ae-e1eb990a4646@forums.neuronootropic.org (705.1ms)
Job exception: end of file reached

I fixed the nginx issue. Turns out there was a save file of the nginx configuration in the sites-enabled directory. Not sure how it got there since I link the files in sites-available to sites-enabled and don’t mess around with the sites-enabled directory.

The issue with G Suite Relay SMTP remains. I don’t understand why. Discourse’s production log mentions no errors.

Discourse doctor:

==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [forums@neuronootropic.org]: forums@neuronootropic.org
Sending mail to forums@neuronootropic.org. . .
Testing sending to forums@neuronootropic.org using smtp-relay.gmail.com:587.
======================================== ERROR ========================================
                                    UNEXPECTED ERROR

end of file reached

====================================== SOLUTION =======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to https://meta.discourse.org/
(And a solution, if you find one!)
=======================================================================================

What does this mean?

1 Like

I, uh…didn’t click save when I set up the relay in G Suite, lol

Email works now. :slight_smile:

3 Likes

This topic was automatically closed 0 minutes after the last reply. New replies are no longer allowed.