Topic: Get list of all users/emails, for every domain

Is it possible to run a quick scripts which gets a list of all the email addresses for every domain?

I want to send out a mass email using bcc letting all the users know of any changes, so ideally this list would be separated by comma.

==== Required information ====
- iRedMail version: 0.8.3 LDAP


Re: Get list of all users/emails, for every domain

You can get all mail users/lists with command "ldapsearch". smile


Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee


Re: Get list of all users/emails, for every domain

Thank you but I dont have any knowledge of working with ldap so the "ldapsearch" hasn't helped.

I was able to simplify one of your examples so this 90% achieves what I need.

Although I find this is also listing the domain names.

#!/usr/bin/env python
# encoding: utf-8

import sys
import ldap

# Note:
#   * bind_dn must have write privilege on LDAP server.
uri = 'ldap://'
basedn = 'o=domains,dc=example,dc=com'
bind_dn = 'cn=Manager,dc=example,dc=com'
bind_pw = 'pass'

# Initialize LDAP connection.
conn = ldap.initialize(uri=uri, trace_level=0,)
conn.bind_s(bind_dn, bind_pw)

# Get all mail users.
allUsers = conn.search_s(

# Print all email users separated by comma
for user in allUsers:
    (dn, entry) = user
    mail = entry['mail'][0]
    if len(mail) > 0:    
        print >> sys.stdout, "%s, " %(mail)

# Unbind connection.