Can't use 'none' DISCOURSE_SMTP_AUTHENTICATION


(Anthony O.) #1

According to Home · discourse/discourse Wiki · GitHub, I should be able to set DISCOURSE_SMTP_AUTHENTICATION: 'none' in the env: section of my app.yml configuration file in order to “completely disable authentication”.

I’m trying to deploy Discourse inside an organization with a private email server which allows to send email from specific IPs internally but requires the applications to disable authentication when talking to it.

When I set DISCOURSE_SMTP_AUTHENTICATION: 'none' or DISCOURSE_SMTP_AUTHENTICATION: none in my app.yml, I obtain those errors in shared/standalone/log/rails/production.log:

Sent mail to me@myserver.tld (3.7ms)
Job exception: wrong authentication type none

It seems that I’m not the only one to have this bug.


(Anthony O.) #2

I have also tested to comment DISCOURSE_SMTP_USER_NAME setting like said here without any success (I still have the same error message).


Job exception: wrong authentication type none
(Felix Freiberger) #3

I have a very similar setup and use these settings:

  ## TODO: The mailserver this Discourse instance will use
  DISCOURSE_SMTP_ADDRESS: mail.my.organization.com # (mandatory)
  #DISCOURSE_SMTP_PORT: 587                        # (optional)
  #DISCOURSE_SMTP_USER_NAME: user@example.com      # (optional)
  #DISCOURSE_SMTP_PASSWORD: pa$$word               # (optional)
  DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

(Joshua Rosenfeld) #4

Same here. We have no auth set up for email (at least as far as Discourse is concerned).


(Anthony O.) #5

And did you (@jomaxro or @fefrei) updated your Discourse instance since November 22, 2016?
Because @iarwain seems to have the same problem as me since this date and says it was working previously.

The only difference I can see between your configuration and mine is that I did not comment DISCOURSE_SMTP_PORT. I will try this tomorrow (hoping that port 25 is the default one).


(Joshua Rosenfeld) #6

Yes. I’ve updated my instance many times since then - we’re on the absolute latest version of Discourse.

Edit: Let me SSH in and grab my config for you. One moment.

Edit 2: @anthony-o here you go:

## TODO: The SMTP mail server used to validate new accounts and send notifications
DISCOURSE_SMTP_ADDRESS: mail.rpi.edu         # required
DISCOURSE_SMTP_PORT: 25                        # (optional, default 587)
#DISCOURSE_SMTP_USER_NAME: *redacted*      # required
#DISCOURSE_SMTP_PASSWORD: *redacted*               # required, WARNING the char '#' in pw can cause problems!
DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

Note: Our SMTP server requires authentication to work, but because our Discourse instance in on a subdomain which doesn’t have an account that works for mail (mismatch in domains), we got a special IP based exception on the mail server from the postmaster.


(Felix Freiberger) #7

My Discourse installs closely follow the latest beta.


(Iarwain) #8

I haven’t tinkered with it for a while, I’ll need to try it again with the latest.

Last time I investigated, RoR’s ActionMailer::Base would only work without authentication if its :authentication settings field was not defined. However, if my memory serves me well, Discourse would pass it :plain by default when the DISCOURSE_SMTP_USER_NAME and DISCOURSE_SMTP_PASSWORD were not defined.

Again, I haven’t touched it since mid-November, I’ll check it again in the coming days.


(Iarwain) #9

I did a try with Discourse 1.3.10 (docker version) and I can confirm it’s now working for me as well, with the same configuration file as before.


(Anthony O.) #10

So here are my tests.

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
DISCOURSE_SMTP_PORT: 25
#DISCOURSE_SMTP_USER_NAME: myusername@server.tld
#DISCOURSE_SMTP_AUTHENTICATION: none
#DISCOURSE_SMTP_PASSWORD: ""
DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Here the error is “Job exception: SMTP-AUTH requested but missing secret phrase”.

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
DISCOURSE_SMTP_PORT: 25
#DISCOURSE_SMTP_USER_NAME: myusername@server.tld
DISCOURSE_SMTP_AUTHENTICATION: none
#DISCOURSE_SMTP_PASSWORD: ""
DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Here the error is “Job exception: wrong authentication type none”.

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
DISCOURSE_SMTP_PORT: 25
#DISCOURSE_SMTP_USER_NAME: myusername@server.tld
DISCOURSE_SMTP_AUTHENTICATION: ""
#DISCOURSE_SMTP_PASSWORD: ""
DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Here it’s back to “Job exception: SMTP-AUTH requested but missing secret phrase”.

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
DISCOURSE_SMTP_PORT: 25
DISCOURSE_SMTP_USER_NAME: myusername@server.tld
#DISCOURSE_SMTP_AUTHENTICATION: ""
DISCOURSE_SMTP_PASSWORD: ""
DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Same error “Job exception: SMTP-AUTH requested but missing secret phrase”.

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
#DISCOURSE_SMTP_PORT: 25
#DISCOURSE_SMTP_USER_NAME: myusername@server.tld
#DISCOURSE_SMTP_AUTHENTICATION: ""
#DISCOURSE_SMTP_PASSWORD: ""
#DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Same error.

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
#DISCOURSE_SMTP_PORT: 25
#DISCOURSE_SMTP_USER_NAME: myusername@server.tld
DISCOURSE_SMTP_AUTHENTICATION: 'none'
#DISCOURSE_SMTP_PASSWORD: ""
#DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Back to “Job exception: wrong authentication type none”.

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
#DISCOURSE_SMTP_PORT: 25
#DISCOURSE_SMTP_USER_NAME: myusername@server.tld
#DISCOURSE_SMTP_AUTHENTICATION: 'none'
DISCOURSE_SMTP_PASSWORD: "none"
#DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Here I’ve got “Job exception: 504 5.7.4 Unrecognized authentication type” (that’s at least a reply of the SMTP server I suppose).

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
#DISCOURSE_SMTP_PORT: 25
#DISCOURSE_SMTP_USER_NAME: myusername@server.tld
#DISCOURSE_SMTP_AUTHENTICATION: 'none'
DISCOURSE_SMTP_PASSWORD: "none"
DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)

Same error as last one.

So I’m a bit confused, I think there is really a bug in Discourse that doesn’t support real none authentication type.
@jomaxro, I’m sure that you didn’t defined DISCOURSE_SMTP_AUTHENTICATION so plain is used, and that means that your SMTP server accepts any authentication (username / password) from the Discourse host, am I wrong?


(Anthony O.) #11

I’ve checked that other topic and what @NULLpointer suggested doesn’t seem to work anymore (at least, it is not working for me now).
It seems that @snarke and @homebrewhops had once the same requirement, are you guys up to date with the latest Discourse version and still use a SMTP server without any authentication?


(Joshua Rosenfeld) #12

OK - so you’re right at the limit of my email knowledge here…if I recall correctly (and there’s no guarantee of that), our SMTP server does not require authentication, however, something will block all email that isn’t properly authenticated (with username/password) or coming from a whitelisted IP.


(Anthony O.) #13

At last I’ve managed to make it working!

For my configuration tests I was using the following command:

sudo ./launcher destroy app && sudo ./launcher start app

I’ve finally executed the rebuild command

sudo ./launcher rebuild app

with the following configuration (all other non displayed DISCOURSE_SMTP_* parameter were commented)

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
DISCOURSE_SMTP_AUTHENTICATION: none
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

and the mail was finally sent, so I could continue my installation!


(Homebrew Hops) #14

Thank you @anthony-o!!

The key was: (all other non displayed DISCOURSE_SMTP_ parameter were commented)*

DISCOURSE_SMTP_ADDRESS: my.smtp.server.tld
DISCOURSE_SMTP_PORT: 25
DISCOURSE_SMTP_AUTHENTICATION: none
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none