邮件与 smtp.office365.com

I’m working through Troubleshooting email on a new Discourse install to work out why mail is not going out on a new discourse instance.

I am able to send mail from the device using swaks

I can telnet into the mail server smtp.office365.com 587 (after setting a fully qualified domain name)

Looks like no errors on the production log.

tail -f shared/web_only/log/rails/production.log
Started POST "/u/action/send_activation_email" for 115.64.14.90 at 2019-12-23 08:20:28 +0000
Processing by UsersController#send_activation_email as */*
  Parameters: {"username"=>"csmu"}
  Rendering text template
  Rendered text template (Duration: 0.1ms | Allocations: 1)
Completed 200 OK in 36ms (Views: 1.0ms | ActiveRecord: 0.0ms | Allocations: 4557)

I see things like this

Cannot open main log file "/var/log/exim4/mainlog"

when I run tail -f shared/web_only/log/var-log/mail.log

Any ideas on why “/var/log/exim4/mainlog” would be locked out and referenced in shared/web_only/log/var-log/mail.log ?

该日志是误报。

主要问题在于与 smtp.office365.com 通信。

  1. 必须将设备设置为使用有效的完全限定域名。在此之前,执行 telnet smtp.office365.com 587 会失败。
  2. 必须在 YAML 文件中设置正确的配置,特别是 DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_ADDRESS: smtp.office365.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: discourse@domain
  DISCOURSE_SMTP_PASSWORD: "validPassword"
  DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_ENABLE_START_TLS: true
  1. 必须设置 SiteSetting.notification_email:
./launcher enter web_only
root@discourse-web-only:/var/www/discourse# rails console
[1] pry(main)> SiteSetting.notification_email = "discourse@domain"
[2] pry(main)> exit
root@discourse-web-only:/var/www/discourse# exit
  1. 重启容器:
./launcher destroy web_only
./launcher start web_only
  1. 任务完成!