Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Jun 2004
    Posts
    28

    Default Need a script to export list of all emails.

    So SPAM has been a constant pain in everyones side for the last... 10 years. We have a great solution in place, but only one problem. We need a full list of all the email addresses being hosted on our server right now. Well with close to 200 domains on each of our servers, its a daunting task to go from server to server listing out all of the email addresses. Not to mention, but tomorrow, someone mad add a new email, and they would be without protection.

    So the question is, is there an easy why to locally list out all e-mail addresses?

    If that is possiable, is there a way to list out all of the forwards and lists addresses?

  2. #2
    Member
    Join Date
    Jun 2004
    Posts
    28

    Default

    Let me be more specific about this. I do not want someone to write the script for me, I need someone to tell me where I can find this information, or how I can get the list. I can do everything else.

    Thanks for the hints.

  3. #3
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    This should get you started:

    find /home/*/etc/*/passwd

    The email addresses are the username (the first field)
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  4. #4
    Member PWSowner's Avatar
    Join Date
    Nov 2001
    Location
    ON, Canada
    Posts
    2,994

    Default

    All forwarders are in /etc/valiases.
    Mike
    WHM and cPanel Scripts (join our "Scripts Club")
    D/A Photography

  5. #5
    Registered User
    Join Date
    Feb 2007
    Posts
    3

    Default Need More Help...

    Hey All,

    I am not a linux admin at all, therefore I need more help getting the email address list. Can someone that maybe already wrote the script post or send me a copy and I can modify it to work on our system? I am very familar with scripting on a Windows box, but not on a *nix system at all and I need a list of email addresses so that they can run thru out gateway servers before it reaches this CPanel box.

    Thanks!
    Grant Griffith

  6. #6
    Member TheIdeaMan's Avatar
    Join Date
    Apr 2005
    Posts
    9

    Lightbulb One possible solution for all email accounts for an entire WHM installation

    Here's a rather kludgy solution that works, but could certainly be improved.

    /etc/valiases/* contains all the forwarding accounts.
    /etc/vdomainaliases/* contains all the domain forwarders.

    The tricky one is the actual accounts. They live in /etc/vmail/passwd.* files.

    My method for retrieving all of the above was a combination of find and cat (run these in a directory you can save to):
    Code:
    find /etc/valiases/* -exec cat {}\; > valiases
    find /etc/vdomainaliases/* -exec cat {}\; > vdomainaliases
    find /etc/vmail/passwd.* -exec cat {}\; > vmail
    The next thing I did was to parse the vmail message via TextWrangler (which uses grep) to output just the directories of each account:

    1. Used the regex below to find all lines not containing account info (including trailing hard return); replaced them with nothing to remove them
    Code:
    /etc/(.*)\s
    Pulled out just the path where the e-mail for that inbox resides
    Code:
    (.*)::(.*):(.*)
    Replaced the above with \2 in the grep that comes with TextWranger

    After running the above, I put that file back on the server and ran this (vmail being the original file name, and vmail_space being the output file name):
    Code:
    cat vmail | xargs du -sh > vmail_space
    That gave me a file containing the same info as the original file plus current disk usage for each account.

    That file could be parsed further to output e-mail addresses rather than path names, but that should help get you started.

    Hope that's helpful to someone else trying to get a complete list of e-mail addresses out for a cPanel/WHM server.

    The other option I was considering was using the cPanel API--which should also work, but take a bit more coding.

Similar Threads & Tags
Similar threads

  1. Export emails/forwarders
    By notuo in forum Feature Requests for cPanel/WHM
    Replies: 0
    Last Post: 03-13-2010, 10:52 AM
  2. Is there an export emails/forwarders
    By notuo in forum New User Questions
    Replies: 5
    Last Post: 03-12-2010, 11:38 AM
  3. Replies: 0
    Last Post: 05-04-2009, 03:57 PM
  4. Export Emails?
    By lakkinit in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 07-30-2006, 04:48 PM
  5. Export Mailman list emails
    By gourou76 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 09-25-2005, 08:52 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube