3

I have looked through every single bit of documentation I can find on this matter, and cannot figure this out. There must be people out there using Sendgrid as SMTP for discourse blogs, but I cannot figure out how.

Here's my app.yml setup:

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en
  UNICORN_WORKERS: 3
  DISCOURSE_DEVELOPER_EMAILS: 'admin@my_domain.com'
  DISCOURSE_HOSTNAME: 'my_domain.com'
  DISCOURSE_RELATIVE_URL_ROOT: /forum

  ## TODO: The mailserver this Discourse instance will use
  DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: apikey
  DISCOURSE_SMTP_PASSWORD: API_KEY
  DISCOURSE_SMTP_ENABLE_START_TLS: true

Obviously my_domain and API_KEY are replaced for the proper values. I have triple checked that these things are correct. I have rebuilt the app via launcher rebuild app many times.

The discourse admin UI shows these settings:

enter image description here

However, when I try to send any email, I get a popup that says:

There was a problem sending the test email. Please double-check your mail settings, verify that your host is not blocking mail connections, and try again.

The actual logs on the server aren't very helpful:

Sent mail to test@my_email.com (91.2ms)
Completed 422 Unprocessable Entity in 287ms (Views: 0.2ms | ActiveRecord: 0.4ms)

But when I check the "Skipped" tab of the admin email UI, I see that the "Skip Reason" is [Sender] 550 Unauthenticated senders not allowed - so I assume this is an authentication problem with SendGrid. How can I resolve this?

j_d
  • 2,818
  • 9
  • 50
  • 91
  • 1
    Everything looks good to me. Verify 1) your API key has permission to send email and 2) you are copying the actual API key (displayed only once upon creation) rather than the API key ID. – bwest Nov 25 '16 at 16:12

2 Answers2

0

"Unauthenticated Senders not allowed" is a SendGrid-specific error that explicitly means that your system isn't sending the AUTH command. So even though you have authentication plain set, something is overriding that, and not attempting to authenticate when connecting to SendGrid.

jacobmovingfwd
  • 2,185
  • 14
  • 11
0

Have you enabled "Mail Send" for that API Key?

enter image description here

brahnp
  • 2,276
  • 1
  • 17
  • 22