Send password reset emails in bulk?

I think using an import script would be a better idea for creating that many users, but that’s off-topic :upside_down_face:
Anyway, you’d reach the rate limit if you send the email in the script as well.

If you want to slow down the email sending process, you can add a sleep(x) (x in seconds) in the ruby loop, and it must be adapted to whatever the rate limit(s) is (are).

If you intend to let your script run for a while, use a session manager such as screen or tmux.

user = User.find_by(username: 'alehandrof')

if user
  email_token = user.email_tokens.create(email: user.email)
  Jobs.enqueue(:critical_user_email, type: :forgot_password, user_id: user.id, email_token: email_token.token)
end

There is no need to create a Ruby file for this; you can run it in the Rails console (./launcher enter app then rails c).