Discourse app.yml doesn't like email password contain "#"

I’m using discourse V1.8.0.beta5 +202

I tried my Gmail account with contain “#” and rebuild app, but couldn’t send test email at admin/email.

I changed my Gmail password without “#” and rebuild app, then send test email works fine.

1 Like

Did you read
https://meta.discourse.org/t/bug-smtp-password-field-does-not-escape-comment-sign-hash/23344/

4 Likes

Yes this is mentioned in the app.yml help but you would not see it as part of the discourse-setup questions, it is true.

1 Like

Sorry, I didn’t read it, tried few hours to identify the issue.

It’s hard to read the comments in app.yml due to the color in VI editor (sorry I’m new in Linux and don’t know how to change color setting in VI), can we mention this issue as part of the discouse-setup?

Seems annoying to mention it there since it will only affect people who have # in their password. Password is put in quotes so that should work, shouldn’t it @pfaffman ?

1 Like

I would think so, but my read of the (really, really old) linked topic is that even with single quotes it wasn’t working.

Yes. Discourse-setup puts double-quotes around the password. If pups and/or docker do the right thing with

  DISCOURSE_SMTP_PASSWORD: "hise@#ijflkjfpassword"

then it should work. N.B. that discourse-setup strips that comment about the #. If we want that comment then we need to put it on standalone.yml on the line above it.

2 Likes

So this should not be an issue @felix. Did you use discourse-setup program as documented in our official setup doc?

I followed steps at Set up Discourse in the cloud in under 30 minutes which is using discourse-setup.

But I can’t remember which email ( I have two email address, one password contains “#” and another one doesn’t) was used for discourse-setup.

What I can remember is DISCOURSE_SMTP_PASSWORD: do have double-quotes around the password when I open by sudo vi app.yml. And send test email function only works if the password doesn’t contains “#”.

So it seems that SMTP passwords with # in them just don’t work? And ./discourse-setup should tell people that they should get a different password?

We are not sure. I believe with double quotes around it, it should work. It should be tested.

I “tested” and the docker that gets called at the end of a rebuild has the SMTP password in single quotes. Like this:

'DISCOURSE_SMTP_PASSWORD=this@!#paswwored' -e 

I am not willing to contrive an actual test to see what password gets sent to an SMTP server. To recap, the OP presents evidence that it doesn’t work.

Docs say pretty clearly not to use Gmail for mail sending. The recommended services don’t (in my experience) create passwords with hashes in them. Seems like an edge case, but I can have ./discourse-setup check for hashes in passwords if @codinghorror wants.

2 Likes

We can probably leave it be for now.

1 Like

It’s passed correctly to Docker if you use the quotes. The problem is that once it ends up inside discourse.conf, it’s not quoted there - and then # is interpreted as beginning of the comment for that line.

Note that this is very to trip up if you 1) use a mail service that lets you provide your own password, and 2) use a strong password generator. Just spent several days trying to figure out why mail wasn’t working on a fresh Discourse docker install, and this was the culprit.

2 Likes

Passwords containing # are a problem in mySQL too. I know there are ways of fixing it but I have resorted to not using # characters in mySQL or Discourse passwords. There are other great special characters that we can use but we all seem to be addicted to # … me included :joy:

1 Like

That suggests a double quoting trick may work, eg:

DISCOURSE_SMTP_PASSWORD: "'#1passwordEVAR'"