This PR backtracks a fair bit on this one FEATURE: Use group SMTP settings for sending user notification emails (initial) by martin-brennan · Pull Request #13220 · discourse/discourse · GitHub.
Instead of sending the group SMTP email for each user via
UserNotifications, we are changing to send only one email with the existing
Jobs::GroupSmtpEmail job and
GroupSmtpMailer. We are changing this job and mailer along with
PostAlerter to make the first topic allowed user the
to_address for the email and any other
topic_allowed_users to be the CC address on the email. This is to cut down on emails sent via SMTP, which is subject to daily limits from providers such as Gmail. We log these details in the
EmailLog table now.
In addition to this, we have changed
PostAlerter to no longer rely on incoming email email addresses for sending the
GroupSmtpEmail job. This was unreliable as a user’s email could have changed in the meantime. Also it was a little overcomplicated to use the incoming email records – it is far simpler to reason about to just use topic allowed users.
Most importantly this PR contains breaking changes for IMAP functionality. IMAP will no longer work after this change. This is because we are no longer making outbound
IncomingEmail records in the
GroupSmtpMailer. This IMAP functionality needs to be revisited at a later date. I think the best thing to do would be to have a table called
ExternalEmailMetadata or something similar, that will store imap UIDs, message IDs, and possibly even provider specific data like gmail thread IDs. This breaking change has been blessed by @SamSaffron.