# What email addresses are configured?

**URL:** https://meta.discourse.org/t/what-email-addresses-are-configured/272301
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [July 20, 2023, 3:30pm UTC](https://meta.discourse.org/t/what-email-addresses-are-configured/272301 "2023-07-20T15:30:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [July 20, 2023, 3:30pm UTC](https://meta.discourse.org/t/what-email-addresses-are-configured/272301/1 "2023-07-20T15:30:57Z")

</div>

When you use `email_in` functionality, you should keep track of what emails are configured and associated with a category or a group. This #data-explorer query will show you a list of category slug or group name and associated email address so you can copy-paste it into a post to get a clickable list of such associations, e.g., to verify that the description mentions the right email address, or to verify your Mail Transfer Agent setup.

Use with Import: [configured-email-addresses.dcquery.json](https://meta.discourse.org/uploads/short-url/pLzuC9AgqtTvYfjRuKr9EfruSum.json) (1.2 KB)

```sql
-- Return all configured emails for categories and groups, ordered by name
--
-- Build category slugs
WITH cat_slug AS (
-- Capture category slug to make it clickable in a post
SELECT CONCAT('#', c.slug) AS identifier, c.id
FROM categories c 
WHERE c.parent_category_id IS NULL
GROUP BY identifier, c.id
UNION ALL
-- Do this for subcategories as well
SELECT CONCAT('#', p.slug, ':', c.slug) AS identifier, c.id
FROM categories c, categories p
WHERE c.parent_category_id = p.id
GROUP BY identifier, c.id
ORDER BY identifier
)
-- Capture @group, email pairs
SELECT CONCAT('@', g.name) AS name, g.incoming_email AS email
FROM groups g
WHERE g.incoming_email IS NOT NULL
GROUP BY name, email
UNION ALL
-- Capture #category, email pairs
SELECT cs.identifier AS name, c.email_in AS email
FROM categories c, cat_slug cs
WHERE c.id = cs.id AND c.email_in IS NOT NULL
GROUP by cs.identifier, name, email
-- Provide a nice alphabetically ordered list
ORDER BY name

```

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [July 20, 2023, 3:41pm UTC](https://meta.discourse.org/t/what-email-addresses-are-configured/272301/2 "2023-07-20T15:41:59Z")

</div>

> [@hellekin](#):
>
> When you use `email_in` functionality, you should keep track of what emails are configured and associated with a category or a group

I _really_ like this and think it’s a good candidate for supporting in core

---

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [July 20, 2023, 3:45pm UTC](https://meta.discourse.org/t/what-email-addresses-are-configured/272301/3 "2023-07-20T15:45:15Z")

</div>

I guess you would like to see `NULL` results as well so you can ensure `mailing_list_mode` works for all cases.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [July 20, 2023, 4:27pm UTC](https://meta.discourse.org/t/what-email-addresses-are-configured/272301/6 "2023-07-20T16:27:00Z")

</div>

Sounds interesting. How did you imagine core supporting this? Adding a report somewhere maybe?

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [July 20, 2023, 4:30pm UTC](https://meta.discourse.org/t/what-email-addresses-are-configured/272301/9 "2023-07-20T16:30:30Z")

</div>

Yeah, I think this kind of thing could be useful as a default admin report.

---

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [July 21, 2023, 9:01am UTC](https://meta.discourse.org/t/what-email-addresses-are-configured/272301/10 "2023-07-21T09:01:57Z")

</div>

I just noticed that the above SQL query does not take into account pipe-separated [multiple email addresses](https://meta.discourse.org/t/multiple-email-addresses-for-a-group/38193/9) for groups and categories.
