Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 21, 2013, 01:23 AM   #1
fortytwoeleven
macrumors newbie
 
Join Date: Aug 2012
Mailing list / Mailchimp?

Hi,
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
fortytwoeleven is offline   0 Reply With Quote
Old Feb 21, 2013, 02:26 AM   #2
SrWebDeveloper
macrumors 68000
 
SrWebDeveloper's Avatar
 
Join Date: Dec 2007
Location: Alexandria, VA, USA
 
see vendor information in user profile
Quote:
Originally Posted by fortytwoeleven View Post
Hi,
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
For the pre-built solution via cPanel: http://docs.cpanel.net/twiki/bin/vie...s/MailingLists

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:

PHP Code:
#!/usr/local/bin/php 
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:

PHP Code:
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); 
      
$i_limit++; 
    }         
  } 
         
  
fclose($fp); 
         
  return 
$email
}  

/* Begin parsing the content of the email */

$myemail=mailRead(-1);

/* 

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.
__________________
Jim Goldbloom
Sr. Web Developer, owner GoldTechPro, LLC
http://www.GoldTechPro.com

Last edited by SrWebDeveloper; Feb 21, 2013 at 02:40 AM. Reason: Added some code to help manual solution
SrWebDeveloper is offline   0 Reply With Quote
Old Feb 21, 2013, 11:06 PM   #3
fortytwoeleven
Thread Starter
macrumors newbie
 
Join Date: Aug 2012
Thanks for your help!
It's really appreciated!! This script should work
fortytwoeleven is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:52 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC