Page 1 of 1
Build message?
Posted: Wed Aug 01, 2007 11:00 pm
by Kaitlyn2004
How can I "build" the message so that I could, for example, write it to a file rather than actually SEND it?
Including headers and everything, of course...
Re: Build message?
Posted: Thu Aug 02, 2007 2:56 am
by Chris Corbyn
Kaitlyn2004 wrote:How can I "build" the message so that I could, for example, write it to a file rather than actually SEND it?
Including headers and everything, of course...
Easy way:
Code: Select all
$stream =& $message->build();
file_put_contents($file, $stream->readFull());
I the message is huge and would take PHP over its memory limit you can stream it into a file instead:
Code: Select all
$fp = fopen($file, "wb");
$stream =& $message->build();
while (false !== $bytes = $stream->read(8192)) {
fwrite($fp, $bytes);
}
fclose($fp);