# List all users with a given email domain

**URL:** https://meta.discourse.org/t/list-all-users-with-a-given-email-domain/323707
**Category:** Support
**Created:** [August 28, 2024, 1:44am UTC](https://meta.discourse.org/t/list-all-users-with-a-given-email-domain/323707 "2024-08-28T01:44:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)
#### Post date: [August 28, 2024, 1:44am UTC](https://meta.discourse.org/t/list-all-users-with-a-given-email-domain/323707/1 "2024-08-28T01:44:59Z")

</div>

I am having trouble diagnosing strange non deliverability of mail to all users in Nederlands with .nl domains.

How can I get a list of emails of users with a given domain, or even a regex?

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 28, 2024, 2:19am UTC](https://meta.discourse.org/t/list-all-users-with-a-given-email-domain/323707/2 "2024-08-28T02:19:51Z")

</div>

You should be able to do this by going to the admin - active users list at `your-site/admin/users/list/active` then type the email domain in the search filter

 ![Screenshot 2024-08-27 at 7.19.13 PM](https://global.discourse-cdn.com/meta/original/4X/6/a/6/6a68446e652c0310b732b3002062e1a980be1b8f.png)

also, these topics might help you:

> [@Troubleshooting Outgoing Email](https://meta.discourse.org/t/troubleshooting-outgoing-email/271484):
>
> bookmark This is an #explanation guide discussing how admins can troubleshoot outgoing email from a Discourse site. person_raising_hand Required user level: Administrator Discourse relies heavily on email for user notifications and account management tasks. If users are unable to receive emails from your Discourse site, this can lead to a variety of problems, including missed notifications and account management issues. Summary In this documentation, you will learn: How to check sent …

> [@Troubleshoot email on a new Discourse install](https://meta.discourse.org/t/troubleshoot-email-on-a-new-discourse-install/16326):
>
> You just installed Discourse via [the install guide](https://github.com/discourse/discourse/blob/main/docs/INSTALL.md), but email doesn’t seem to work. Unfortunately this means you can’t log in as an admin to finalize the install. cry Let’s troubleshootize! Try the doctor woman_health_workerIf you run ./discourse-doctor it will check several ways that your mail configuration might be broken, and offer advice. Try that first. Did you enter email settings correctly? The simplest way is to run ./discourse-setup again. Did you enter everything correctly? B…

---

<div class="post-metadata">

### Author: ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)
#### Post date: [August 28, 2024, 5:10am UTC](https://meta.discourse.org/t/list-all-users-with-a-given-email-domain/323707/3 "2024-08-28T05:10:14Z")

</div>

@Lilly thanks. I did not say but I was really looking for some report from querying the datazbase in rails or something.

---

<div class="post-metadata">

### Author: ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)
#### Post date: [August 28, 2024, 5:13am UTC](https://meta.discourse.org/t/list-all-users-with-a-given-email-domain/323707/4 "2024-08-28T05:13:02Z")

</div>

@Lilly Thanks. There is nothing wrong with our mail setup, there’s a weird issue between Amazon SES and Nederlands, where all Amazon SES outbound mails get blocked and blacklisted. It’s nothing to do with Discourse - except I wish I could see more of the SMTP error in the Error logs, which cuts off each report just where the error is about to begin. I wonder how to see the full bounce report. [Sorry I have just derailed this into a new thread.]

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 28, 2024, 6:00am UTC](https://meta.discourse.org/t/list-all-users-with-a-given-email-domain/323707/5 "2024-08-28T06:00:58Z")

</div>

You can see them in the Bounced email report at `yoursite/admin/email/bounced`

Or you can use [data explorer](https://meta.discourse.org/t/32566?silent=true) for finding all users of a domain, then export a csv file. maybe something like:

```sql
-- [params]
-- text :domain = example.com

SELECT u.id AS user_id, u.username, ue.email
FROM users u
JOIN user_emails ue ON u.id = ue.user_id
WHERE ue.email LIKE '%' || :domain
  AND ue.primary = true
ORDER BY u.username

```

Or you could make a group and automatically add them to the group

 ![Screenshot 2024-08-27 at 10.59.18 PM](https://global.discourse-cdn.com/meta/original/4X/e/e/8/ee8f5a7e3067b3b384290d69c99fb0755010d440.png)
