Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    1

    Default List of All E-mail Accounts/Aliases?

    Is there a way in WHM/Cpanel to obtain a list of all valid e-mail accounts and aliases that the server has on it?

    We're attempting to integrate all users and domains on our servers with a hosted anti-spam solution and they can synchronize user lists in a number of ways.

    I have full root access, so I can do about anything, just need to be pointed in the right direction.

    _Brendan

  2. #2
    Registered User
    Join Date
    Jul 2008
    Posts
    2

    Default listing all pop accounts in their domains.

    There are a couple of ways that I have seen to do this.

    First, is a command to run from the shell. You may want to APPEND this command into a text file, if you have a lot of accounts on your server, and will run past the line limit in your ssh screen, ie putty, terminal, etc. Also note, there are no 'line breaks' in the command. Sorry, I tried to add the <code> brackets, but it wouldn't let me.

    cat /etc/userdomains | grep -v nobody | while read x; do export DOMAIN=`echo $x | awk -F : '{print $1}'`; export USER=`echo $x | awk '{print $2}'`; for y in `cat /home/$USER/etc/$DOMAIN/passwd | awk -F : '{print $1}'`; do echo $y\@$DOMAIN; done; done

    Second is a script.

    #!/bin/sh -

    #
    # Get a list of domains and POP accounts in each on a cPanel maildir-based server
    #

    FILE="/etc/trueuserdomains"
    total_count=0
    while read line
    do
    domain=$( echo $line | awk 'BEGIN{FS=": "}{print $1}')
    user=$( echo $line | awk 'BEGIN{FS=": "}{print $2}')
    box_count=0
    if [[ -d /home/$user/mail/$domain ]]
    then
    echo "----------------------"
    echo "$domain"
    echo "----------------------"
    for box in `ls /home/$user/mail/$domain | grep -vE "(^cur$|^new$|^tmp$)"`
    do
    echo "$box@$domain"
    ((box_count += 1))
    done
    echo; echo "Total for $domain: $box_count POP boxes"; echo
    ((total_count += $box_count))
    fi
    done < $FILE

    echo; echo "Total POP boxes: $total_count"; echo



    There are probably more ways to go about this process, but like I said, these are the ways I've seen so far.
    Last edited by blainemotsinger; 11-08-2008 at 08:31 AM. Reason: can't use <code> brackets...

Similar Threads & Tags
Similar threads

  1. how to list pop mail accounts
    By vryand in forum cPanel Developers
    Replies: 1
    Last Post: 11-29-2010, 02:43 PM
  2. Mail Account Aliases
    By sparek-3 in forum E-mail Discussions
    Replies: 0
    Last Post: 10-23-2009, 09:10 AM
  3. mail aliases help please
    By modom in forum New User Questions
    Replies: 2
    Last Post: 05-14-2006, 10:09 PM
  4. Mail Aliases Forwards
    By Davec in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 09-28-2005, 10:08 PM
  5. List accounts and mail queue isn't functioning
    By yikin in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 06-09-2003, 04:26 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube