Ok. I have set up a few scripts to go through and email people based on if an email is sent to a certain few email addresses.
So, here's how I have it set up. I have the email addresses set up and forwarded. I forwarded it to:
/home/USERNAME/public_html/email/pipe_it.php
The Pipe_it.php file splits the header and then calls one of two php files (sendit.php or error.php).
Now, I have sent a test email to the address, and it didn't work. Any ideas?
pipe_it.php
#!/usr/local/bin/php
<?php
// read from stdin
$fd = fopen("/dev/stdin", "r+");
$email = "";
while(!feof($fd)){
$email .= fread($fd, 1024);
}
fclose($fd);
// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
for($i=0; $i<count($lines); $i++){
if($splittingheaders){
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if(preg_match("/^Subject: (.*)/", $lines[$i], $matches)){
$subject = $matches[1];
}
if(preg_match("/^From: (.*)/", $lines[$i], $matches)){
$from = $matches[1];
}
if(preg_match("/^To: (.*)/", $lines[$i], $matches)){
$toList = $matches[1];
}
}
else {
// not a header, but message
$message .=$lines[$i].&nquot;\n";
}
if(trim($lines[$i])==""){
// empty line, header section has ended
$splittingheaders = false;
}
}
$dbc = mysql_connect("localhost", "mamasboy_admin", "winfield14");
mysql_select_db("mamasboy_mailingList");
$query = "SELECT Users.*, Subscriptions.*, Lists.* FROM `Users`, `Subscriptions`, `Lists` WHERE Users.Email = '$from' AND Subscriptions.User_ID = Users.User_ID AND Lists.User_ID = Users.User_ID;";
$result = mysql_query($query, $dbc);
$display = mysql_fetch_array($result);
$list_address = $display['Address'];
$email = $dispaly['Email'];
if($from != $email){
include_once 'error.php';
}
else{
include_once 'sendit.php';
}
?>
A small issue I can see is that under cPanel, if I look at the mail forwarders the one I need to forward to pipe_it.php I get this as the forwarder:
/home/mamasboy/public_html/email/pipe_it.php@list.umbcmamasboys.org
I can't get the @list.umbcmamasboys.org to go away. So, in order to alleviate this issue, does anyone know a good tutorial on email piping using PHP And/Or any good scripts I can use?
As a side note, I would LOVE to use CREN's ListProc software, but I don't have a build. If anyone understands building php install scripts, and want to build one, I'd most appreciate it. http://listproc.sourceforge.net
Thanks for the help.
~Brett