Monday, July 17, 2006

php mail2db

#!/usr/local/bin/php -q

$fd = fopen("php://stdin","r");
while (!feof($fd)) {
$data = fgets($fd, 4096);

if ( eregi("^From:",$data) ) {

$email = eregi_replace( "From: ", "", $data);
$email = str_replace ("\n", "", "$email");
}

if ( eregi("^Subject:",$data) ) {

$subject = eregi_replace( "Subject: ", "", $data);
$subject = str_replace ("\n", "", "$subject");
}

if ( eregi("^Reply-To:",$data) ) {

$replyto = eregi_replace( "Reply-To: ", "", $data);
$replyto = str_replace ("\n", "", "$replyto");
}

if ( eregi("^To:",$data) ) {

$autoresponder = eregi_replace( "To: ", "", $data);
$autoresponder = eregi_replace( "<", "", $autoresponder); $autoresponder = eregi_replace( ">", "", $autoresponder);
$autoresponders = strstr($autoresponder, "@");
$id = str_replace ("$autoresponders", "", "$autoresponder");
}

$testdata = "$testdata$data";

}

fclose ($fd);

$body = strstr ($testdata, "\n\n");

No comments:

Post a Comment