note 109704 modified in function.imap-savebody by danbrown

From: Date: Fri, 31 Aug 2012 16:36:42 +0000
Subject: note 109704 modified in function.imap-savebody by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190387@lists.php.net to get a copy of this message
By using imap_fetchbody() you may run in trouble by using too much memory. Using imap_savebody() may prevent this. 

But the content will be encoded, in other words it is useless. Adding a filter can help here.

<?php
$whandle = fopen('./incomming/tmp.tif','w');

stream_filter_append($whandle, 
 'convert.base64-decode',STREAM_FILTER_WRITE);

imap_savebody ($mbox, $whandle, $i, $partcounter++);

fclose($whandle);
?>

NOTE: To find the proper filter you need to check the encoding given by the structure of the body. --was-- By using imap_fetchbody() you may run in trouble by using too much memory. Using imap_savebody() may prevent this. But the content will be encoded, in other words it is useless. Adding a filter can help here. $whandle = fopen('./incomming/tmp.tif','w'); stream_filter_append($whandle, 'convert.base64-decode',STREAM_FILTER_WRITE); imap_savebody ($mbox, $whandle, $i, $partcounter++); fclose($whandle); NOTE: To find the proper filter you need to check the encoding given by the structure of the body. http://php.net/manual/en/function.imap-savebody.php

« previous php.notes (#190387) next »