The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

export email ids list

Discussion in 'E-mail Discussions' started by crazyaboutlinux, Jul 2, 2009.

  1. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    Hi

    again i back after my long vacation

    in cPanel/whm server there is one domain named myest.com & it has more than 500 email ids

    now i want to export that email ids or any alternate way to get list of mail ids ?

    please do reply
     
  2. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Howdy,

    There are a quite a few ways of doing this. To offer you the best method, what are you planning to do with the list?

    Thanks!
     
  3. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    Just want to create mailing list
     
  4. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Howdy,

    Easy enough:

    Code:
    cd /home(x)/user/mail/; ls -a|grep @|awk '{print $2}' FS="."
    should do most of it. The only thing that might be off is the tld that you're using so in my case I added it to this:
    Code:
     cd /home2/fishmail/mail/; ls -a|grep @|awk '{print $2}' FS="."|replace _net .net
    you'll likely need to do the same for your .tld.
     
  5. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    It's very tough to use , however i'll try to do this


    you'll likely need to do the same for your .tld.

    >> i do not understand this

    cd /home(x)/user/mail/; ls -a|grep @|awk '{print $2}' FS="."

    what should replace on (x)

    Is there any easy way to do this ?
     
  6. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Howdy,

    The reason I put "homeX" is some folks have more than one directory. If you don't it'll just be /home. You can get your home folder path from the cPanel page for that user under "Stats". It should look something like this image attached.
     

    Attached Files:

  7. gmaegarro

    gmaegarro Registered

    Joined:
    Jul 5, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Thank you for your discussion. The same problem happened to me. It is very helpful to me.
     
  8. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    I'm glad it helped. I came back and added tags to make it more search-able.
     
  9. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Just a basic expansion on the code line given earlier in this thread
    so it functions as a simple global mail account listing script:
    Code:
    #!/bin/bash
    IFS="$"
    
    cd /home    #Just a nice starting point
    
    ls /var/cpanel/users | while read MUSER; do
      MHOME=$(grep "${MUSER}:" /etc/passwd | cut -d':' -f6 | head -1)
      cd ${MHOME}/mail/
      ls -a | grep '@' | awk '{print $2}' FS="." | replace '_' '.'
    done
    
    Basically reads the list of valid usernames and home directories
    of each of the users on the server and then displays all the email
    accounts that have been created for each irregardless of where the
    home folders are actually stored for each account.

    Don't forget that this will only give you a list of email accounts,
    to find out if any additional mail aliases have been setup or alternate
    names for these accounts, you will want to also look at each of
    the files listed under /etc/valiases where you will find a file named
    for each domain on the server and in that file the list of aliases
    that have been setup for that specific domain.
     
    #9 Spiral, Jul 6, 2009
    Last edited: Jul 7, 2009
  10. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    showoff :P, I mean nice work :)
     
Loading...

Share This Page