# 激活邮件：discourse-doctor 有效，但 discourse 本身无效

**URL:** <https://meta.discourse.org/t/activation-emails-discourse-doctor-works-discourse-itself-does-not/131337>\
**Category:** Self-hosting\
**Created:** [2019 年10 月 18 日 07:22 UTC](https://meta.discourse.org/t/activation-emails-discourse-doctor-works-discourse-itself-does-not/131337 "2019-10-18T07:22:24Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![hexadecagram](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hexadecagram/32/262658_2.png) [@hexadecagram](https://meta.discourse.org/u/hexadecagram)\
发布日期： [2019 年10 月 18 日 07:22 UTC](https://meta.discourse.org/t/activation-emails-discourse-doctor-works-discourse-itself-does-not/131337/1 "2019-10-18T07:22:24Z")

</div>

大家好，

正如标题所说。discourse-doctor 会通过其外部且面向互联网的网络接口（而非 localhost）连接到我的邮件服务器（运行在宿主机上），但 discourse 本身却无法连接。

discourse 没有任何尝试连接的日志记录，既没有出现在 Rails 生产日志中，也没有出现在我的邮件服务器日志中。我甚至对 Docker 接口运行了数据包嗅探器，但也没有看到任何邮件流量。

不过，discourse-doctor 确实在我的邮件服务器上生成了预期的日志条目，并且我可以在邮件客户端中阅读到这些邮件。

我已经使用以下配置重新构建了多次 Docker 容器：

```
## 这是 Discourse Docker 容器的全功能独立模板
##
## 修改此文件后，您必须重新构建
## /var/discourse/launcher rebuild app
##
## 编辑时请*非常*小心！
## YAML 文件对空格或缩进的错误极其敏感！
## 如有需要，请访问 http://www.yamllint.com/ 验证此文件

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## 如果您想添加 Lets Encrypt (https)，请取消注释以下两行
### - "templates/web.ssl.template.yml"
### - "templates/web.letsencrypt.ssl.template.yml"

## 此容器应暴露哪些 TCP/IP 端口？
## 如果您希望 Discourse 与 Apache 或 nginx 等其他 Web 服务器共享端口，
## 请参阅 https://meta.discourse.org/t/17247 了解详情
expose:
  - "127.0.0.1:1234:80" # http
    ### - "127.0.0.1:1235:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## 将 db_shared_buffers 设置为总内存的最大 25%。
  ## 将根据检测到的 RAM 由 bootstrap 自动设置，您也可以覆盖
  db_shared_buffers: "256MB"

  ## 可能改善排序性能，但会增加每个连接的内存使用量
  #db_work_mem: "40MB"

  ## 此容器应使用哪个 Git 版本？（默认：tests-passed）
  #version: tests-passed

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## 支持多少并发 Web 请求？取决于内存和 CPU 核心数。
  ## 将根据检测到的 CPU 由 bootstrap 自动设置，您也可以覆盖
  UNICORN_WORKERS: 4

  ## TODO: 此 Discourse 实例将响应的域名
  ## 必填。Discourse 无法仅使用 IP 地址运行。
  DISCOURSE_HOSTNAME: example.com

  ## 如果您希望容器以与上述指定的相同主机名（-h 选项）启动，请取消注释（默认 "$hostname-$config"）
  #DOCKER_USE_HOSTNAME: true

  ## TODO: 初始注册时将被设为管理员和开发人员的逗号分隔电子邮件列表
  ## 示例：'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'me@another.com'

  ## TODO: 用于验证新账户和发送通知的 SMTP 邮件服务器
  # SMTP 地址、用户名和密码是必需的
  # 警告：SMTP 密码中的字符 '#' 可能会导致问题！
  DISCOURSE_SMTP_ADDRESS: submission.example.com # A 记录有效，但 CNAME 无效
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: somedumbuser
  DISCOURSE_SMTP_PASSWORD: somedumbpass
  #DISCOURSE_SMTP_ENABLE_START_TLS: true # （可选，默认为 true）

  ## 如果您添加了 Lets Encrypt 模板，请取消注释以下行以获取免费 SSL 证书
  LETSENCRYPT_ACCOUNT_EMAIL: ssl@yetanother.com

  ## 此 Discourse 实例的 http 或 https CDN 地址（配置为拉取）
  ## 请参阅 https://meta.discourse.org/t/14857 了解详情
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com

## Docker 容器是无状态的；所有数据都存储在 /shared 中
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## 插件放在这里
## 请参阅 https://meta.discourse.org/t/19157 了解详情
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## 构建后运行的任何自定义命令
run:
  - exec: echo "开始自定义命令"
  ## 如果您想为首次注册设置“发件人”电子邮件地址，请取消注释并修改：
  ## 收到首次注册邮件后，请重新注释该行。该行只需运行一次。
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - replace:
      filename: /etc/nginx/conf.d/discourse.conf
      from: "types {"
      to: |
        set_real_ip_from 0.0.0.0/0;
        real_ip_header X-Forwarded-For;
        real_ip_recursive on;
        types {
  - exec: echo "自定义命令结束"}

```

---

_[View the full topic](https://meta.discourse.org/t/activation-emails-discourse-doctor-works-discourse-itself-does-not/131337)._
