The discussion revolves around the issue of digest emails being triggered after a large post migration from MyBB to Discourse. dandv experienced Gmail’s SMTP rate limiting due to the sudden surge in emails.
dandv suggested adding a warning to disable digest emails before migration, as they were triggered after the import, causing autoresponders from users on vacation.
gerhard explained that digest emails are sent after the import, as Discourse sees users who haven’t visited the forum for a certain amount of time. A possible solution would be to not enable emails after the import or implement a grace period where no digest emails are sent.
neil recommended disabling emails in settings or adding SiteSetting.disable_emails = true to the script to prevent emails from being sent during the import. elberet suggested modifying the ImportScripts::Base#create_user method to prevent digest emails from being sent immediately after the import.
pgr encountered a similar issue and was unsure of the best strategy to adopt, as they wanted to receive admin emails and test user experiences, but prevent unwanted emails. codinghorror stated that migrations should put the site in no-email or staff-only-email mode, and pgr eventually found the solution by setting SiteSetting.disable_emails to non-staff.
I’ve just migrated a large number of posts from MyBB and there were many jobs scheduled. I was using Gmail’s SMTP to send emails (our forum is low volume). The migration seems to have triggered digest email jobs ({"type"=>"digest", "user_id"=>4889, "current_site_id"=>"default"}), and this triggered Gmail’s STMP rate limiting:
Job exception: Wrapped Net::SMTPAuthenticationError: 454 4.7.0 Too many login attempts, please try again later. ow2sm11059574pdb.14 - gsmtp
Would it be possible to not trigger the digest after migration, since it doesn’t exactly make sense to email users of all the “new” posts?
I don’t recall having this problem for other migrations we’ve done for customers, so I am not convinced this is a “bug”. But we’ll take a look, I guess.
Digests have been actually triggered. I’m receiving autoresponders from people on vacation etc. Glad I was using Gmail and didn’t spam absolutely everyone.
I’ve just checked disable digest emails but that should be a big warning before migration. Maybe add it as a comment in the migration script?
The digest mails aren’t sent during the import, they are sent after the import.
During the import all emails are disabled, but as soon as the import is finished and Discourse is started, it sees a bunch of users that haven’t visited the forum for a certain amount of time and begins to send digest emails.
A quick solution would be to not automatically enable emails after the import (still it would send the digest mails as soon as emails would be enabled). A better solution would be some sort of grace period after an import where no digest emails should be sent, but I guess that’s not possible at the moment.
I don’t run imports on production servers with sidekiq running, emails being sent, etc. You definitely want to see what the imported data looks like before going into production with it. Every import is a special snowflake with its own surprises and requirements.
If you are running an import onto a live production site, disable emails in settings, or add this to the initialize method of your script: