List all users with a given email domain

AI-generated summary

A user, Andro, is experiencing issues with email deliverability to users with the .nl domain in the Netherlands. Lilly suggests that the list of emails can be obtained by searching the email domain in the admin active users list at your-site/admin/users/list/active.

However, Andro is looking for a more technical solution, querying the database in Rails. Lilly provides a Data Explorer query to find all users of a domain:

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

Additionally, Lilly mentions that the bounced email report at yoursite/admin/email/bounced can be used to view full bounce reports. The issue with email deliverability is attributed to Amazon SES blocking and blacklisting outbound emails to the Netherlands, unrelated to Discourse.

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?

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

also, these topics might help you:

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

@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.]

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

Or you can use data explorer for finding all users of a domain, then export a csv file. maybe something like:

-- [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