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.

List of all hosted email addresses

Discussion in 'E-mail Discussions' started by John Schmerold, May 1, 2014.

  1. John Schmerold

    John Schmerold Active Member

    Joined:
    Apr 21, 2004
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    st. louis
    cPanel Access Level:
    Root Administrator
    This four liner produces a list of your email addresses, it is helpful if you are using an external spam filter

    #!/bin/bash

    find /etc/valiases/* -type f | xargs -ifile sed -e 's/:.*//' file > /usr/src/getAllEmail.txt

    ls -d /home/*/mail/*/*/ | awk 'BEGIN { ; } ; { ; tcmd = "test -d " $1 ; if(!system(tcmd)){ ; split($1,MyArray,"/") ; print MyArray[6] "@" MyArray[5] ; } ; }' >> /usr/src/getAllEmail.txt

    sed -i -e 's/*.*//' /usr/src/getAllEmail.txt
    sed -i '/^\s*$/d' /usr/src/getAllEmail.txt

    Hope this helps someone.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Thank you for sharing this script. Please note that user-submitted scripts are not tested or supported by cPanel. We encourage everyone to review all aspects of this script before using it on a production server.

    Thank you.
     
Loading...

Share This Page