Test email not sending, 'completed 422 unprocessable entity' in production.log


(Shannon Kern) #1

Hey all! I’m trying to set up our company’s discourse forum but am encountering some issues with emailing. We use GSuite for our e-mail service and I am using GSuite’s SMTP-Relay for my SMTP address. I was not able to get the admin account to send an activation email so in order to continue setting up our forum I set myself as admin in terminal.

I have already gone through every option in the e-mail troubleshooting guide to no avail.

  • My connection is not being blocked when I check with telnet.
  • I ran rails r "SiteSetting.notification_email = 'noreply@MyCompanysWebsite.com'" when I entered the app from terminal because my forum is located on a subdomain of my main company’ website. I also tried this with the -exec command in app.yml.

Here is what my app.yml file reads in the relevant section:

env:
  LANG: en_US.UTF-8
  DISCOURSE_HOSTNAME: forum.MyCompanysWebsite.com

  DISCOURSE_SMTP_ADDRESS: smtp-relay.gmail.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME:
  DISCOURSE_SMTP_PASSWORD:

and here is the log statement that I get when I run tail shared/standalone/log/rails/production.log:

  Parameters: {"email_address"=>"my-email@my-company.com"}
Sent mail to my-email@my-company.com (232.4ms)
Completed 422 Unprocessable Entity in 260ms (Views: 0.2ms | ActiveRecord: 0.5ms)
Started POST "/admin/email/test" for [ip] at 2017-02-07 03:19:14 +0000
Processing by Admin::EmailController#test as */*

I can’t make heads or tails of this & google searches have proven unfruitful. Any ideas about what’s going on?

Thanks!


(Jeff Atwood) #2

The only hits I can find on this have to do with field lengths being changed in Admin, Site Settings. Did you modify any site settings or is everything at default? Is this forum in English? Latest version of Discourse?


(Nam Nguyen) #3

Hi
Try to review your email setting?
Do you enable “access from less secure apps” in Google Account settings? :slight_smile:

Discourse recommend using these email providers


(Shannon Kern) #4

I did not modify any site settings to my knowledge! The forum is set to English default language, and I have the latest version of Discourse.

Thanks for the response!


(Shannon Kern) #5

Hello, thank you for the response!

I cannot enable ‘access from less secure apps’ because:

This setting is not available for accounts with 2-Step Verification enabled. Such accounts require an application-specific password for less secure apps access.

I’m a bit lost what to do with this. Do I need to generate an ‘app password’ and let Discourse access it somehow?

I guess I could try a different provider but I’d like to get it working with my GSuite SMTP if possible.


(Joshua Rosenfeld) #6

If your GSuite account has 2FA enabled, you cannot use your “normal” password for an application that can’t ask you for the second factor of auth (like the 6 digit code). What password did you use in your app.yml? (Don’t share the password, just clarify if you used your “normal” password that you would use to log into Gmail or an application specific password).


(Shannon Kern) #7

I did not specify a password in my app.yml because the SMTP-relay address I’m using says it requires no authentication. I think I’m seeing what might be going wrong here… do I need to provide an application specific password that I generate somewhere in my app.yml to get around the 2 step verification or something? Sorry I am very new to anything related to smtp services!


(Shannon Kern) #8

You know what guys I’m just going to try using SparkPost for this. Thanks for the responses! I don’t really want to mess with our GSuite settings as I’m not super familiar with it and don’t want to mess up any security settings.

Thanks again for help! Have a nice evening.

Sorry for the bother~


(Joshua Rosenfeld) #9

Don’t apologize for bothering! Email is one of the hardest things to configure - I had similar challenges setting up Discourse in an enterprise environment (not using GSuite) that took weeks of troubleshooting with my organizations postmaster to fully resolve.


(Jeff Atwood) #10

Oh sorry I buried the lede here. Looks like the two factor requirement on gmail is a showstopper.

We do not recommend gmail for outgoing mail, though with a paid GSuite account in theory it is possible.


(Régis Hanol) #11