Mail 및 smtp.office365.com

새로운 Discourse 인스턴스에서 메일이 발송되지 않는 원인을 파악하기 위해 Troubleshoot email on a new Discourse install - #2 를 참고하고 있습니다.

swaks를 사용하여 해당 디바이스에서 메일을 발송할 수 있습니다.

(완전 한정 도메인 이름을 설정한 후) 메일 서버 smtp.office365.com 587로 telnet 접속이 가능합니다.

production 로그에는 오류가 보이지 않습니다.

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)
tail -f shared/web_only/log/var-log/mail.log```
을 실행하면 다음과 같은 메시지를 확인합니다.

Cannot open main log file “/var/log/exim4/mainlog”


왜 "/var/log/exim4/mainlog"가 잠금 상태이며 ```shared/web_only/log/var-log/mail.log```에서 참조되는 것일까요? 어떤 아이디어가 있으신가요?

해당 로그는 오탐(false positive)이었습니다.

주된 문제는 smtp.office365.com과의 연결이었습니다.

  1. 장치가 유효한 FQD(Fully Qualified Domain Name, 완전 한정 도메인 이름)를 사용하도록 설정해야 했습니다. 그 전까지
    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. 작업 완료!