Mail and 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 ?

1 Like

That log was a false positive.

The main issue was talking to smtp.office365.com

  1. Had to set the device to use a valid fully qualified domain name. Until then
    telnet smtp.office365.com 587 failed.
  2. Had to set the correct settings in the yaml file especially 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. Had to set the 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. Restarted the container
./launcher destroy web_only
./launcher start web_only
  1. Job done!
4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.