-# Managing emails
+# E-Mail administration tasks
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
```sh
mix pleroma.email test --to root@example.org
```
+
+## Send confirmation emails to all unconfirmed user accounts
+
+=== "OTP"
+
+ ```sh
+ ./bin/pleroma_ctl email send_confirmation_mails
+ ```
+
+=== "From Source"
+
+ ```sh
+ mix pleroma.email send_confirmation_mails
+ ```
use Mix.Task
import Mix.Pleroma
- @shortdoc "Simple Email test"
+ @shortdoc "Email administrative tasks"
@moduledoc File.read!("docs/administration/CLI_tasks/email.md")
def run(["test" | args]) do
shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
end
+
+ def run(["resend_confirmation_emails"]) do
+ start_pleroma()
+
+ Pleroma.User.Query.build(%{
+ local: true,
+ deactivated: false,
+ confirmation_pending: true,
+ invisible: false
+ })
+ |> Pleroma.RepoStreamer.chunk_stream(500)
+ |> Stream.each(fn users ->
+ users
+ |> Enum.each(fn user -> Pleroma.User.send_confirmation_email(user) end)
+ end)
+ |> Stream.run()
+ end
end
|> where([u], not is_nil(u.nickname))
end
+ defp compose_query({:confirmation_pending, bool}, query) do
+ where(query, [u], u.confirmation_pending == ^bool)
+ end
+
defp compose_query({:need_approval, _}, query) do
where(query, [u], u.approval_pending)
end