I am creating an intranet system for a security company, and every now and then they recieve a report as an email attachment from a monitoring company when a burglar alarm has gone off. I have created a script that extracts the necessary info from this report to go into the database so the intranet can access it. This is done through the file() function. I now need to some how create a script that will automatically recieve the email, read the attachent, and then process the code I have already written. I have created a seperate email address, and have successfully set it to pipe to a script (pipe.php) and send a test email to verify it works. Any ideas what I can do to make this script extract the attachment from an email, and then read it? Heres the code I have so far to read a locally saved report:
Code: Select all
<?php
$lines=file('report.psr');
$text=array();
foreach($lines as $numb=>$line)
{
$text[]=$line;
}
foreach($text as $line => $text) {
$report[]=substr($text,3,9);
}
$accountnumber=$report[193];
?>
Im not sure why but I could only retrieve the values from the array once I had set it through 2 different arrays ($lines to $text to $report). Im afraid I can't send a sample report if anyone wants to try the script, they contain confidential data.
Sorry if this isnt too clear, ask me if you want any more details.
Jack
P.S sorry if this thread is in the wrong place, this is my first post on this forum!