Accepting Email Subscription Through Email (Email Piping)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prevmedone
Forum Newbie
Posts: 2
Joined: Thu Oct 02, 2003 5:57 pm
Location: New Orleans, Louisiana

Accepting Email Subscription Through Email (Email Piping)

Post by prevmedone »

Hello

I have an autoresponder program that is written in PHP, and I would like for it to accept email subscriptions via remote site (blank emails), and I am trying to do so via .forward and/or .procmailrc mail. I have done the following:

1. I implemented one php script to capture the email contents as below: I uploaded this
file to /home/soldiers/public_html/adtrack/script.php


#!/usr/local/lib/php

<?php

// read from stdin

$fd = fopen("php://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];

$text = "subject: $subject \r\n";

}

if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {

$from = $matches[1];

$text .= "from: $from \r\n";

}

} else {

// not a header, but message

$message .= $lines[$i]."\n";



}



$text .= "message: $message";



mail("fisherelectronics@usa.net","redirectmail",$text);



if (trim($lines[$i])=="") {

// empty line, header section has ended

$splittingheaders = false;

}

}

$ffpath=realpath(".") ."/temp/" ."mail.txt";

$fp = fopen ($ffpath, "w");

$rr=@fwrite($fp,$text);

fclose($fp);

}





2. I created .procmailrc file and uploaded to the parent directory of public_html in which the contents are:


:0c |/usr/local/lib/php /home/soldiers/public_html/adtrack/script.php




Please assist as to were I may have confused myself.

or give better idea of how I may accomplish this task.

Thank You so much

Richard[/b]
Post Reply