Email Sending Issues Occured on Different Email Provider on notification_email and reply_by_email_addresses

Hello, recently I’ve encountered some issues on configuring the email sender as QQ Exmail (a.k.a 腾讯企业邮箱). My email configuration is listed as below:

DISCOURSE_SMTP_ADDRESS: smtp.exmail.qq.com
DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_ENABLE_START_TLS: true
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: username@domain.tld
DISCOURSE_SMTP_PASSWORD: ***

I’ve also configured the notification_email in the setting panel.

However, when I tried to send test email from the panel, the system always returns that 501 mail from address must be same as authorization user .

I’ve double checked that the DISCOURSE_SMTP_USER_NAME and the notification_email are the same email address, and my SMTP settings also passed the test on SMTP Test Tool .

As I currently have no idea which part of my email configuration, may it be any way for me debug the issue or check the raw email that the discourse instance tried to send in order for me to diagnostic whether the from: address section of the email is correct?

Any help or comment is highly appreciated.

Here are some posts that I referenced for configuring the email.
https://community.jenkins-zh.cn/t/discourse/202

After some investigation, I guess this problem may be related to the conflict between the notification_email and reply_by_email_addresses. When the two variables are both configured, the outgoing email seems using reply_by_email_addresses as their from: address, which may be related to the code below:

However, when I switch the notification email to office 365 with the similar SMTP configuration, the email sends without any problem.

  #DISCOURSE_SMTP_ADDRESS: outlook.office365.com
  #DISCOURSE_SMTP_AUTHENTICATION: login
  #DISCOURSE_SMTP_ENABLE_START_TLS: true
  #DISCOURSE_SMTP_PORT: 587
  #DISCOURSE_SMTP_USER_NAME: 365@domain.tld
  #DISCOURSE_SMTP_PASSWORD: ***

Guessing the reason for this different behavior may be that office365 does not verify the from: field when sending mail, but only rewrites the from: field to the username of the office365 account when sending mail, and QQ Exmail will verify the from field of the sent mail, while incorrect from: field could cause the 501 error mentioned above.

1 Like