SMTP usernames with backslash?

Dear all,

I’m trying to set up Discourse on a virtual server. I can use the organisation’s SMTP-server for mail, so that is fine and I got everything set-up, except for one proplem: no emails are being sent. I then created an admin account with

./launcher enter app
rake admin:create

which nicely worked, and then looked at the mail setting. There I found the likely reason that no emails are being sent: my SMTP username is of the form “foo\bar”, where “foo” is a given prefix for a subgroup of users on that system, and “bar” is my account name. Then there is the backslash in between.

When I look at the /admin/email page in my Discourse installation, what I get shown as user_name is “foobar” without the backslash. I then tried escaping in app.yml, after looking up YAML syntax.

I tried:

DISCOURSE_SMTP_USER_NAME: foo\bar
DISCOURSE_SMTP_USER_NAME: 'foo\bar'
DISCOURSE_SMTP_USER_NAME: "foo\\bar"
DISCOURSE_SMTP_USER_NAME: foo\\bar

All give the same result (after rebuilding Discourse every time): user_name: foobar

I don’t know where the backslash might get stripped. I saw no warning on special characters but the escaping I tried did not result in a change at Discourse installation level. I tried sending an email every time after rebuild (from the /admin/email page) but I always receive an error when sending.

Can someone help, please?

If you’re authenticating against a modern windows domain infrastructure, you can probably use the bar@foo format.

Otherwise it looks like quotes (double quotes) is the proper method:

If neither work, your organisation might be blocking the ports you need to SMTP from your Discourse box.

إعجاب واحد (1)

I’m wondering if escaping the backslash once is enough.

In my limited experience with JavaScript, it depends on how many times the string is passed around. eg.

step one -> step two -> step three
foo\\bar -> foo\bar -> foobar

Maybe try foo\\\\bar ?

step one -> step two -> step three
foo\\\\bar -> foo\\bar -> foo\bar

إعجاب واحد (1)

Thank you for the hints. Whether they will work I don’t know because some additional issues with the SMTP account came up. But, that said, bar@foo.local is at least parsed properly in the /admin/mail tab. However, also only if enclosed in double quotes "bar@foo.local". Else only bar@foo arrives.

@Mittineague: Inside double quotes I’ll need to escape a backslash likely twice, but I’ll test that later.

Currently I’m battling that I did some configuration as admin and for the second time only get a blank screen. 1st time this happened I could not get Discourse back and had to do a complete reinstall… Different topic.

So 4 backslashes were needed. Thanks again. Still have email issues, but not because of the backslash :wink:

إعجابَين (2)