# 批量发送密码重置电子邮件吗？

**URL:** <https://meta.discourse.org/t/send-password-reset-emails-in-bulk/241012>\
**Category:** Support\
**Created:** [2018年二月5日 11:21 UTC](https://meta.discourse.org/t/send-password-reset-emails-in-bulk/241012 "2018-02-05T11:21:04Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![CarlosDaniel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carlosdaniel/32/273223_2.png) [@CarlosDaniel](https://meta.discourse.org/u/CarlosDaniel)\
**Post date:** [2022年十月5日 11:04 UTC](https://meta.discourse.org/t/send-password-reset-emails-in-bulk/241012/7 "2022-10-05T11:04:58Z")

</div>

在此更正一下——该脚本确实有效。我只需要：

```plaintext
cd /var/discourse
sudo ./launcher enter app

```

然后创建文件：

```plaintext
// 创建文件
touch password.rb

```

然后添加以下代码：

```plaintext
email_token = nil

User.all.each do |u|
  email_token = u.email_tokens.create(email: u.email)
  Jobs.enqueue(:critical_user_email, type: :forgot_password, user_id: u.id, email_token: email_token.token)
  sleep(5)
end

```

最后，运行它：

```plaintext
rails r password.rb

```

它确实对我有效 🙂。

---

_[View the full topic](https://meta.discourse.org/t/send-password-reset-emails-in-bulk/241012)._
