The Discourse-setup fails when the SMTP username contains a / character. According to RFC3696, / is a valid character for an SMTP username. The issue arises from the sed command using / as the separator.
hellekin proposes a solution by replacing the / separator with another character, such as :, in the sed commands. The corrected lines are:
smtp_domain=$(echo $notification_email | sed -e "s:.*@::")
sed -i -e "s]^ #\?DISCOURSE_SMTP_USER_NAME:.*] DISCOURSE_SMTP_USER_NAME: $smtp_user_name]w $changelog" $web_file
A patch is provided by hellekin, which fixes the sed commands to allow for RFC3696 compliant email addresses. Firepup650 points out a mistake in the patch, and hellekin updates the patch accordingly. sam welcomes a PR for the fix and suggests that someone can submit the patch.
/ is a valid character for an SMTP username, according to RFC3696:
Without quotes, local-parts may consist of any combination of
alphabetic characters, digits, or any of the special characters
! # $ % & ' * + - / = ? ^ _ ` . { | } ~
Corrective path
The script fails on a sed command that, by default, uses / as the separator.
Since the colon (:) is not an acceptable character for the local-part of an email address, it may be used instead of /, without any side-effect another character such as a comma or semi-colon could bring (except that colons in the sed patterns must be escaped — note that using ] instead would remove the need to escape colons):
line 589: smtp_domain=$(echo $notification_email | sed -e "s/.*@//") should be smtp_domain=$(echo $notification_email | sed -e "s:.*@::")
line 648: DISCOURSE_DEVELOPER_EMAILS uses , to separate email addresses, so it could safely use : as well
line 675 is the source of my bug: sed -i -e "s/^ #\?DISCOURSE_SMTP_USER_NAME:.*/ DISCOURSE_SMTP_USER_NAME: $smtp_user_name/w $changelog" $web_file may be sed -i -e "s:^ #\?DISCOURSE_SMTP_USER_NAME\:.*: DISCOURSE_SMTP_USER_NAME\: $smtp_user_name:w $changelog" $web_file or sed -i -e "s]^ #\?DISCOURSE_SMTP_USER_NAME:.*] DISCOURSE_SMTP_USER_NAME: $smtp_user_name]w $changelog" $web_file
I’m not in control of that code, but I wrote it long ago. That’s a great solution. I should have thought of that. I’d guess that a PR would be welcome.
Unfortunately I lost access to my Github account. They ask me for some code and I don’t use the linked email anymore, so I simply stopped using that platform except to clone public code.