# Discourse-setup 在 SMTP 用户名中使用 / 时失败

**URL:** <https://meta.discourse.org/t/discourse-setup-fails-on-smtp-username-with-a/272514>\
**Category:** Bug\
**Tags:** pr-welcome\
**Created:** [2023 年7 月 22 日 16:23 UTC](https://meta.discourse.org/t/discourse-setup-fails-on-smtp-username-with-a/272514 "2023-07-22T16:23:44Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

作者： ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)\
发布日期： [2023 年7 月 24 日 14:12 UTC](https://meta.discourse.org/t/discourse-setup-fails-on-smtp-username-with-a/272514/5 "2023-07-24T14:12:21Z")

</div>

这是一个补丁：

修复 sed 命令，以允许符合 RFC3696 的电子邮件地址

[discourse-setup.fix-272514.patch.gz](https://meta.discourse.org/uploads/short-url/rCrNhJTV1WisbJMDTGzXsGnh2Z8.gz) (601 字节)

```diff
diff --git a/discourse-setup b/discourse-setup
index 0daafcb..121982e 100755
--- a/discourse-setup
+++ b/discourse-setup
@@ -586,7 +586,7 @@ ask_user_for_config() {
     fi

     # set smtp_domain default value here rather than use Rails default of localhost
- smtp_domain=$(echo $notification_email | sed -e "s/.*@//")
+ smtp_domain=$(echo $notification_email | sed -e "s].*@]]")

     if [! -z $letsencrypt_account_email]
     then
@@ -645,7 +645,7 @@ ask_user_for_config() {
     update_ok="n"
   fi

- sed -i -e "s/^ DISCOURSE_DEVELOPER_EMAILS:.*/ DISCOURSE_DEVELOPER_EMAILS: \'$developer_emails\'/w $changelog" $web_file
+ sed -i -e "s]^ DISCOURSE_DEVELOPER_EMAILS:.*] DISCOURSE_DEVELOPER_EMAILS: \'$developer_emails\']w $changelog" $web_file
   if [-s $changelog]
   then
     rm $changelog
@@ -672,7 +672,7 @@ ask_user_for_config() {
     update_ok="n"
   fi

- sed -i -e "s/^ #\?DISCOURSE_SMTP_USER_NAME:.*/ DISCOURSE_SMTP_USER_NAME: $smtp_user_name/w $changelog" $web_file
+ sed -i -e "s]^ #\?DISCOURSE_SMTP_USER_NAME:.*] DISCOURSE_SMTP_USER_NAME: $smtp_user_name]w $changelog" $web_file
   if [-s $changelog]
   then
     rm $changelog
@@ -681,7 +681,7 @@ ask_user_for_config() {
     update_ok="n"
   fi

- sed -i -e "s/^ #\?DISCOURSE_NOTIFICATION_EMAIL:.*/ DISCOURSE_NOTIFICATION_EMAIL: $notification_email/w $changelog" $web_file
+ sed -i -e "s]^ #\?DISCOURSE_NOTIFICATION_EMAIL:.*] DISCOURSE_NOTIFICATION_EMAIL: $notification_email]w $changelog" $web_file
   if [-s $changelog]
   then
     rm $changelog
@@ -745,7 +745,7 @@ ask_user_for_config() {
   then
     echo "Enabling Let's Encrypt"
   fi
- sed -i -e "s/^ #\?LETSENCRYPT_ACCOUNT_EMAIL:.*/ LETSENCRYPT_ACCOUNT_EMAIL: $letsencrypt_account_email/w $changelog" $web_file
+ sed -i -e "s]^ #\?LETSENCRYPT_ACCOUNT_EMAIL:.*] LETSENCRYPT_ACCOUNT_EMAIL: $letsencrypt_account_email]w $changelog" $web_file
   if [-s $changelog]
   then
     rm $changelog

```

---

_[View the full topic](https://meta.discourse.org/t/discourse-setup-fails-on-smtp-username-with-a/272514)._
