I have a question, my newly installed Carbonio email server has 1,200 accounts and I need to add them all to a distribution list, however I have not found a way to do it all at once, or at least 20 at a time, is there a way? So far I have only been able to do it one by one but at a certain number it no longer allows me to add more.
You have 2 ways to do it:
1- The hard way, on the Linux prompt
- As 'zextras' user export all accounts with "zmprov -l gaa > /tmp/accounts", then edit /tmp/accounts and remove the system accounts (galsync, spam, ham, admin).
- Add the members with a loop like:
for a in $(cat /tmp/accounts); do zmprov adlm your_mailing_list@foo.org $a done
2-The easy way (but with sophisticated LDAP query)
- Use "Dynamic Mode" in the mailing list creation on Carbonio's admin console. This lets you define a LDAP query to create your mailing list. The best thing is that you can also use extra fields like "Company", "Address" or even "Pager" or "Fax number" as ways to identify company departments, or branches, or any other features, even if they have nothing to do with a fax or a pager.
In this way you can create dynamic groups that update automatically when new members arrive or quit your organisation.
@cvidal your script is awesome.... I would like to contribute to make it a bit more efficient, if you let me?
So, in you script zmprov runs to every single account. It works but it's pretty slow, and when you have to add 1200 accounts it might take a long time to process.
I have been using a different approach: create a file with all commands without zmprov and then pipe it to zmprov just once. Let me show how:
>/tmp/add_list.txt for $email in $(zmprov -l gaa | sort) ; do echo "adlm your_mailing_list@foo.org $email" >> /tmp/add_list.txt done cat /tmp/add_list.txt | zmprov
This way zmprov runs just once and add all those entries on the LDAP super fast.
Give it a try and let me know what you think 😀
Regards
Thank you, at the time I solved it and the process was very fast, now I have a new scenario, I have in a txt file line by line all the accounts that I want to add to a new distribution list, what would be the best option to create the list as well from the script, thanks in advance
Use cli zmprov command and a simple shell script "for" loop =)