Re: Piping email into a php script
| From: | Philip Hallstrom | Date: | Mon, 04 Apr 2005 20:00:23 +0000 |
| Subject: | Re: Piping email into a php script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-212206@lists.php.net to get a copy of this message | ||
$buffer = file_get_contents("php://stdin");
will read the contents of standard input into the string $buffer.
-philip
On Mon, 4 Apr 2005, Jeff McKeon wrote:
Running PHP 4.3.9, apache, mysql, qmail I know it's possible to pipe an incoming mail message to a script in qmial by creating a .qmail file for the user like: |script What I'd like to do is pipe incoming mail for a specific user into a php script that parses it out (using mailparse I imagine) and puts the pieces into a database table. On PHP.net I see an example like this on the function page for Mailparse: [SNIP] <?php $buffer = [...] // Mail Content from pipe or whatever $mail = mailparse_msg_create(); mailparse_msg_parse($mail,$buffer); $struct = mailparse_msg_get_structure($mail); foreach($struct as $st) { $section = mailparse_msg_get_part($mail, $st); $info = mailparse_msg_get_part_data($section); print_r($info); } ?> [SNIP] This looks like it will work so long as I put the required database interface code in the "foreach" section. However I'm a little stuck on how to actually pipe the file into the script so that it winds up in the $buffer variable. Can anyone give me a clue as to how I can do this?
Thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php