Mailing list / Mailchimp?

Discussion in 'Web Design and Development' started by fortytwoeleven, Feb 20, 2013.

  1. fortytwoeleven macrumors newbie

    Aug 24, 2012
    Hope this is in the right section.. I thought I would ask here because I can't regt much of a response from other forums.

    I'm looking for a way that I can send an email to a default address. and once that adress receives the email it triggers it to mail it out to a mailing list of emails.

    Is there something out there already like this?
    Also I am hoping to do it so the mailing list is 0 maintenance, such as it pulls the email addresses from WHM / Cpanel / WHMCS do I don't have to keep adding and removing emails.

    Any advice would be great! thank you :)
  2. SrWebDeveloper, Feb 21, 2013
    Last edited: Feb 21, 2013

    SrWebDeveloper macrumors 68000


    Dec 7, 2007
    Alexandria, VA, USA
    For the pre-built solution via cPanel:

    If you wish to customize your own solution (i.e. DIY from scratch, no cPanel dependencies):

    This is a web development forum so the responses here might be skewed towards LAMP based solutions, i.e. PHP scripts. My response is that way and focuses on cPanel which is very common.

    1) Setup an email account with forwarding in cPanel
    2) In the forwarding pipe it to a custom PHP script, i.e.

    |php -q -n /PATH/TO/SCRIPT/parse.php

    3) For parse.php:

    Make sure the very first line is:

    Adjust path to your PHP, if not sure type in "which php" via shell, or check output of phpinfo() in a test script on that server to get PHP information.

    Chmod 755 (make sure script is executable permissions wise)

    Note that the script, invoked this way, reads email from STDIN. You *must* read in the email contents to avoid bounce back, but since you're using the email content for your mailing list, that works out just fine.

    Below is an example script to do just that, edit to suit your needs, don't just copy and paste as this is to demonstrate the concept, of course:

    function mailRead($i_klimit ""

    // Reads piped mail from STDIN 
      // Optional $i_klimit specifies after how many kilobytes the reading should stop 
      // Default is 1024k. This is very generous for plain or formatted text. 
      // Set to -1 for unlimited (i.e. read entire email) 
      // This will prevent the script running into "out of memory" errors when dealing with large mails. 

    if ($i_klimit == "") { 
    $i_klimit 1024
    $fp fopen("php://stdin""r"); 
    $email ""
      if (
    $i_klimit == -1) { 
        while (!
    feof($fp)) { 
    $email .= fread($fp1024); 
      } else { 
        while (!
    feof($fp) && $i_limit $i_klimit) { 
    $email .= fread($fp1024); 

    /* Begin parsing the content of the email */



    At this point either invoke your external mailer script if you got one which
    delivers this email to a list via exec() or system() or add your own PHP code 
    here which  does whatever you want, noting $myemail contains the content.
    For example I might create a list of addresses in a MySQL database
    and process each one here. 


    That's the procedure, the rest is up to you of course.
  3. fortytwoeleven thread starter macrumors newbie

    Aug 24, 2012
    Thanks for your help!
    It's really appreciated!! This script should work :)

Share This Page