Don't trigger digests on migration?

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.

Thanks. This is what I see right now:


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?

1 Like

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.

This is happening since @neil commited

which has been discussed in

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:

SiteSetting.disable_emails = true

and you’ll probably have other setting you’ll want to change.


Still, once emails are enabled, users will get digest emails right away. Couldn’t we add something like this to ImportScripts::Base#create_user:

opts[:last_emailed_at] = opts.fetch(:last_emailed_at,

I realize this is an old thread, but I just ran into this problem, which caused emails to be sent to users from a migration server that was just meant as a test.

First thing I’d like to ask is if anything has changed in this regard, in the recent years?

Then another problem is that I am unsure of the best strategy to adopt here. I can disable all emails, and I can disable digests, but on the other hand I want to get Discourse’s admin emails, and to be able to have some users from my team start playing with Discourse, and particularly I want to get the user experience right in terms of logins, user email validations, requirements to change their old, migrated passwords to something more complex, etc. - and this requires email.

Once that is achieved, I guess I will also like to get test email digests for a small group of users, to see how they look and play with options and design.

So, how can I prevent unwanted emails, but still have some chance to get emails so I can evaluate the migration properly? Thanks in advance for any advice.

I guess what I am talking about here is a way to hack an email addresses white list that could be enforced during a migration…

Something is amiss with your migration, because all our tools always put the site in no-email or staff-only-email mode, and have for years.

1 Like

I am using a script based on the kunena3.rb script, and the changes I made are not related to emails. I might be using a months-old version of that script, but certainly not a years-old version.

This is what I see in the logs

Could it be something related to individual users, like an activation flag? Or are you referring to system-wide options?


Yep, there’s a single site setting that disables email entirely or sets it to staff-only. Migrations always set this.

Scroll up in the topic to see what that setting is ↑ ↑

So here it is…

Or from code:

SiteSetting.disable_emails = "non-staff"

My setting when I got there was no disable, meaning enabled :scream:

But my script doesn’t touch this setting; and in base.rb it is set to yes. So I currently have no explanation for how emails got enabled (or failed to get disabled) :thinking:

I even checked the code of the only plugin I’m using, discourse-migratepassword, but no mention of this option there, either.

No reply needed - my problem is solved, thanks for that, I am left wondering what happened but that is a minor concern at this point.