# Bulk adding auto approve email domains

**URL:** https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932
**Category:** Support
**Created:** [July 14, 2022, 12:48pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932 "2022-07-14T12:48:03Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![robbie.morrison](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robbie.morrison](https://meta.discourse.org/u/robbie.morrison)
#### Post date: [July 14, 2022, 12:48pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/1 "2022-07-14T12:48:03Z")

</div>

Continuing the discussion from [Formalized assignment and possible logging of pending applications](https://meta.discourse.org/t/formalized-assignment-and-possible-logging-of-pending-applications/232724)

Is the value for &nbsp;`auto approve email domains`&nbsp; a space‑separated string? Or comma‑separated or newline‑separated? TIA,&nbsp;R

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 25, 2022, 7:30pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/2 "2022-07-25T19:30:13Z")

</div>

In the UI, you add them one by one using the ➕ button (and then confirming with the green tick)

 ![auto approve email domains](https://global.discourse-cdn.com/meta/original/4X/e/3/b/e3bd94997ea101533bd65a5ef81837d846275a80.png)

---

<div class="post-metadata">

### Author: ![robbie.morrison](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robbie.morrison](https://meta.discourse.org/u/robbie.morrison)
#### Post date: [July 25, 2022, 7:55pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/3 "2022-07-25T19:55:16Z")

</div>

Many thanks @JammyDodger. We were thinking of being a **bit more automated**. We planned to export our current list of emails, then extract those that matched the [hipo list](https://github.com/Hipo/university-domains-list) of university domains, and then import that new list into discourse under the `auto approve email domains` key. Using [python](https://en.wikipedia.org/wiki/Python_%28programming_language%29) and [pandas](https://en.wikipedia.org/wiki/Pandas_%28software%29) for the numercal processing. I&nbsp;guess that route is not supported? Or do we, or can we, have programmatic access? (PS: with reference to your screenshot, [gmail.com](http://gmail.com) is that last domain name we would dream of automatically approving.)

Oh, and can we use **wildcards** like: `*.tu‑berlin.de` to account for departmental information being included, say `maths.tu‑berlin.de`.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 25, 2022, 8:17pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/4 "2022-07-25T20:17:02Z")

</div>

I had a feeling I was being far too simplistic. 🙂 I think this would benefit from splitting into a new #Support topic to get some more knowledgeable eyes on it. 👍

> [@robbie.morrison](#):
>
> (PS: with reference to your screenshot, [gmail.com](http://gmail.com) is that last domain name we would dream of automatically approving.)

This I can appreciate. 🙂 Don’t worry though, it was a screenshot of a mockup on my test site, not the settings here on Meta. 🙂

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [July 25, 2022, 8:40pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/5 "2022-07-25T20:40:56Z")

</div>

> [@robbie.morrison](#):
>
> Oh, and can we use **wildcards** like: `*.tu‑berlin.de` to account for departmental information being included, say `maths.tu‑berlin.de`.

Sadly, I believe this is not possible. I made a feature request mentioning this:

> [@Allow automatic group membership based on subdomain](https://meta.discourse.org/t/allow-automatic-group-membership-based-on-subdomain/213615/1):
>
> An alternative (if you were worried about users who currently _intend_ to exclude subdomains from automatic membership) would be to allow wildcards, e.g. to type `*.domain.com` for automatic group membership.

My main proposal was probably _not_ what you’d want (it would mean if you added [tu-berlin.de](http://tu-berlin.de) it would include [maths.tu-berlin.de](http://maths.tu-berlin.de) and every other department).

---

<div class="post-metadata">

### Author: ![robbie.morrison](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robbie.morrison](https://meta.discourse.org/u/robbie.morrison)
#### Post date: [July 25, 2022, 9:07pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/6 "2022-07-25T21:07:53Z")

</div>

> [@Jonathan5](#):
>
> My main proposal was probably _not_ what you’d want (it would mean if you added [tu-berlin.de](http://tu-berlin.de) it would include [maths.tu-berlin.de](http://maths.tu-berlin.de) and every other department).

That is exactly the behavior I was seeking.

---

<div class="post-metadata">

### Author: ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)
#### Post date: [July 25, 2022, 9:48pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/7 "2022-07-25T21:48:32Z")

</div>

> [@robbie.morrison](#):
>
> We planned to export our current list of emails, then extract those that matched the [hipo list](https://github.com/Hipo/university-domains-list) of university domains, and then import that new list into discourse under the `auto approve email domains` key. Using [python](https://en.wikipedia.org/wiki/Python_%28programming_language%29) and [pandas](https://en.wikipedia.org/wiki/Pandas_%28software%29) for the numercal processing. I guess that route is not supported? Or do we, or can we, have programmatic access?

If you have access to the Rails console, then you can set `allowed email domains` to an a pipe-delimited string with arbitrarily many hostnames, so that sounds workable.

Not sure why you would need numerical processing though; this can be done with standard UNIX tooling.

This gives you the list of domains from the Hipo list:

```bash
curl -L 'https://github.com/Hipo/university-domains-list/blob/master/world_universities_and_domains.json?raw=true' |
  jq '.[].domains' |
  jq -r add |
  sort -u

```

If you saved that as `domains.txt`, and assuming you have a file with email addresses named `emails.txt`, you could get the subset of domains to allowlist with this:

```bash
grep -if domains.txt emails.txt |
  cut -d @ -f 2 |
  sort -u

```

That is, even if the domain list contains just `tusculum.edu`, an email like `some.student@mail.tusculum.edu` would yield `mail.tusculum.edu` which is the hostname you actually want to allowlist, as opposed to the apex.

Then it’s just a matter of setting a pipe delimited string containing these domains. Does that work for you?

---

<div class="post-metadata">

### Author: ![robbie.morrison](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robbie.morrison](https://meta.discourse.org/u/robbie.morrison)
#### Post date: [July 25, 2022, 10:02pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/8 "2022-07-25T22:02:30Z")

</div>

Thanks @leonardo. I&nbsp;will need to ask my discourse hosting provider if I&nbsp;can access the Ruby on Rails console (I&nbsp;tend to suspect not?). But will submit a question tomorrow.

I am comfortable with the bash shell utilities you mention (I&nbsp;started on SCO UnixWare circa 1997 before migrating to Linux). One reason for adopting python is that future admins of our forum are more likely to be knowledgeable about python.

---

<div class="post-metadata">

### Author: ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)
#### Post date: [July 25, 2022, 10:13pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/9 "2022-07-25T22:13:05Z")

</div>

Perfect; Python should make it equally easy.

> [@robbie.morrison](#):
>
> will need to ask my discourse hosting provider if I can access the Ruby on Rails console

Failing that, you can use the API (with an admin account) to `PUT /admin/site_settings/allowed_email_domains` with a form encoded payload like this:

`allowed_email_domains=zuyd.nl%7Czzgc.edu.cn%7Czzut.edu.cn`

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [July 25, 2022, 10:57pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/10 "2022-07-25T22:57:24Z")

</div>

> [@robbie.morrison](#):
>
> if I can access the Ruby on Rails console (I tend to suspect not?). But will submit a question tomorrow.

No, you cannot, but you can always use the API (as Leonardo suggested) or simply open a ticket with the command you want us to run for you. We’ll even send you back the output 😉

---

<div class="post-metadata">

### Author: ![robbie.morrison](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robbie.morrison](https://meta.discourse.org/u/robbie.morrison)
#### Post date: [July 26, 2022, 6:13am UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/11 "2022-07-26T06:13:24Z")

</div>

@RGJ many thanks. One other thought, probably completely without merit. But being able to upload an overarching database, such as the [hipo list](https://github.com/Hipo/university-domains-list), to a discourse instance and have discourse do this kind of screening and processing would, from a users perspective, be ideal. 🦥

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 9, 2022, 12:29pm UTC](https://meta.discourse.org/t/bulk-adding-auto-approve-email-domains/233932/12 "2022-11-09T12:29:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
