[thelist] Incoming Mail and PHP

Kasimir K evolt at kasimir-k.fi
Wed Aug 11 07:29:12 CDT 2004


Hello,

I'm trying to receive mail with PHP, as instructed here:

http://evolt.org/article/Incoming_Mail_and_PHP/18/27914/index.html

Below is a part of the script I'm using. I have a table "test" with 
autoincrement "id" field and text field "message". First I insert 
current time in "message", and then replace it with the message as it is 
read.

With plain text email it works fine. But if I have an attachment, the 
message is not read at all. But if I change
fread(STDIN, 8192) to fread(STDIN, 64)
I get the headers almost:
...
Subject: test 0811n
Content-Type: multipart/mix

and if I further reduce the length down to fread(STDIN, 1) I get a tad more:
...
Subject: test 0811s
Content-Type: multipart/mixed;
  boundary=

Too bad I can't reduce the length below 1 :-/

Any ideas what is happening here, and why, and how to get over it?

thanks,
.kasimir

======================================================================

if(!defined("STDIN"))
{
	define("STDIN", fopen('php://stdin','r'));
}
mysql_query('
	INSERT test
	SET message = NOW()
');
$id = mysql_insert_id();
$email = "";
do
{
	$data = fread(STDIN, 8192);
	$email .= $data;
	if (strlen($data) == 0)
	{
		break;
	}
	mysql_query('
		UPDATE test
		SET message = "'.$email.'"
		WHERE id = "'.$id.'"
	');
}
while(true);
fclose($fd);


More information about the thelist mailing list