Valen
08-06-2004, 03:30 PM
This may not be something that's done very often (unless you're writing an online mail system I guess) but I'm trying to figure out how to pipe an incoming email to a PHP script. I'm hosting with pair.com (they run freeBSD), and their control panel allows you to do this. The problem is, it doesn't work for me. :)
What I tried to do is pipe mail to a script which then uses php://stdin to try to grab the email. I found one article (seems to be plastered all over the web) that shows how to do this -- http://gvtulder.f2o.org/articles/incoming-mail/ From my observation, it seems that the script is never executed (either that or it can't grab the email). It's very strange because if I send an email, it doesn't bounce. But once I delete the script file from the server it instantly bounces.
Any *nix experts here who can help? :)
Here's the code (pretty much like in the article except I try to dump it to a file)
<?php
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
$outfile = fopen("test.txt", "w");
fwrite($outfile, $email);
fclose($outfile);
?>
What I tried to do is pipe mail to a script which then uses php://stdin to try to grab the email. I found one article (seems to be plastered all over the web) that shows how to do this -- http://gvtulder.f2o.org/articles/incoming-mail/ From my observation, it seems that the script is never executed (either that or it can't grab the email). It's very strange because if I send an email, it doesn't bounce. But once I delete the script file from the server it instantly bounces.
Any *nix experts here who can help? :)
Here's the code (pretty much like in the article except I try to dump it to a file)
<?php
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
$outfile = fopen("test.txt", "w");
fwrite($outfile, $email);
fclose($outfile);
?>