Re: Save email as .eml file
| From: | Handa Utsav | Date: | Fri, 20 Jul 2007 04:16:43 +0000 |
| Subject: | Re: Save email as .eml file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-259204@lists.php.net to get a copy of this message | ||
Hi there,
Well it can be easily done. Just input your mail (make 'procmail' fwd
it) to your script & script would save it as .eml .
Try to use the following code for script :
######## CODE #####################
<?php
$email = "";
## Read
E-mail
$fd = fopen("php://stdin", "r");
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
# Save email
$handle = fopen("$path/$file_name.eml","a+");
if (!$handle) {
fwrite($log_handle," Failed ");
}
else {
fwrite($handle,"$email");
fclose($handle);
}
?>
Hope this helps you out.
Greetings
Utsav Handa