What email addresses are configured?

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 (1.2 KB)

-- 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
3 Likes

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

4 Likes

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

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

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

1 Like

I just noticed that the above SQL query does not take into account pipe-separated multiple email addresses for groups and categories.