Results 1 to 6 of 6

Thread: Extract emails

  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    45

    Default Extract emails

    how can i extract all emails addresses from my server i would like to send an email to all my users

  2. #2
    Member
    Join Date
    Jan 2005
    Location
    Earth
    Posts
    1,052

    Default

    If you wish to send an email to all the users hosted on your server, you can do so from WHM >> Account Functions >> Email All Users. If you wish to send email to Resellers accounts as well, check the box "Send Email to Reseller's Customers".

  3. #3
    Registered User
    Join Date
    Aug 2003
    Location
    Austin, TX
    Posts
    2

    Default Send email to all users

    I realize that WHM has this function, but we'd like to build a local copy of all user emails to send them "pretty" HTML emails re: server upgrades, new offerings, etc.

    How can we get the list, rather than just send the email?

  4. #4
    Member
    Join Date
    Jun 2005
    Posts
    159

    Default

    User email addresses are stored in /home/username/.contactemail, IF the user has set their email address.


    for x in `ls /home` ; do strings /home/$x/.contactemail >> /some/path/to/outputfile ; done

  5. #5
    Member carlaron's Avatar
    Join Date
    Jun 2003
    Posts
    45

    Default List ALL email users

    If you want to send an email to ALL your email users... not just to the contact emails (half of which are out of date or not monitored by anyone with half a brain)... Here is a command-line PHP script to list all mailbox accounts. I used this when I needed to tell ALL of my email users about my planned upgrade from mbox to maildir, so they would know why their mailboxes where unavailable for as much as several hours (depending on the number of mailboxes you have on your server), and that NeoMail would no longer be available.

    #!/usr/local/bin/php
    <?php
    $folderlist = `ls -d /home/*/mail/*/*`;
    $list_array = explode("\n",$folderlist);
    foreach($list_array as $folder){
    if(is_dir($folder)){
    $folder_array = explode("/",$folder);
    print $folder_array[5] . "@" . $folder_array[4] ."\n";
    }
    }
    ?>

  6. #6
    Member
    Join Date
    Sep 2004
    Posts
    5

    Default AWK instead of PHP

    I tried the php script above and remembered my PHP is locked down, so I can't execute the system calls. So I wrote a little awk script to do the same thing. Please let me know if you see an improvement!

    I used the same logic found in the php script. Thanks for the inspiration to do something cool!

    Hans

    --------------------------------------------------------

    #!/bin/awk -f
    #
    # File: getAllEmail.awk
    #
    # This awk script takes the input of ls -d /home/*/mail/*/*
    # checks to see if the directory exists, then outputs the email address. My example
    # outputs them to a text file called emailaddress.txt
    #
    # I wrote it to get all the email addresses out of my cpanel box.
    # You are free to use this program for your own purposes. If you
    # improve it, please let me know. If it is horribly flawed, please let me know.
    #
    # Author: Hans C. Kaspersetz
    # Date: 10/27/2007
    # Email: hans [at] cyberxdesigns [dot] com
    #
    # Usage on cpaneli cli> ls -d /home/*/mail/*/*/ | getAllEmail.awk > emailaddress.txt

    BEGIN {
    }
    {
    tcmd = "test -d " $1
    if(!system(tcmd)){
    split($1,MyArray,"/")
    print MyArray[6] "@" MyArray[5]
    }
    }

Similar Threads

  1. Cant Extract...
    By insafmpm in forum New User Questions
    Replies: 5
    Last Post: 02-20-2010, 02:59 AM
  2. Cant Extract...
    By insafmpm in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 02-19-2010, 06:47 AM
  3. Can,t extract certain plug in
    By aquarius in forum cPanel Developers
    Replies: 4
    Last Post: 02-08-2008, 09:26 PM
  4. Extract Backup
    By eglim in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 03-23-2006, 07:06 AM
  5. Extract to wiki?
    By Karpinski in forum New User Questions
    Replies: 1
    Last Post: 11-04-2005, 04:41 AM