Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, Good Morning to all. D

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
Hello,

Good Morning to all.

Does anyone know if it is possible to have PHP read/filter
incoming mails in a mail box and display the filtered
message on a web page?

For exemple, doing that I could try to match the word "run" found in the message and make PHP do something if the word is really found inside the mail.

Any idea?
 
Sure this is possible.

On a Unix/Linux/BSD based system, mail is kept in a user's mail spool. The mail spool is simply a file, like /var/spool/username

PHP has a rich set of file access and regular expression functions. So you would use PHP to open the mail spool file:

$fp = fopen("/var/spool/username", "r");

...and then parse through the file one-line-at-a-time until you found the word "run":

while (!feof($fp)){
$line = fgets($fp, 100);
if eregi("run", $line){
echo "we found the word run";
break;
}
}

Of course, you'll actually have to do much more reqular expression stuff to keep track of where you are inside the mail spool because mail spools are a bunch of emails stuck together. But this is the basic idea I think.

Bryan




 
Dear Brian,

Thanks a lot for your VERY VERY helpful message.
I will give it a try soon.

Bye bye...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top