@ -4,10 +4,10 @@
* ZipDownload
* ZipDownload
*
*
* Plugin to allow the download of all message attachments in one zip file
* Plugin to allow the download of all message attachments in one zip file
* and downloading of many messages in one go.
* and also download of many messages in one go.
*
*
* @version 3.1
* @requires php_zip extension (including ZipArchive class)
* @requires php_zip extension (including ZipArchive class)
*
* @author Philip Weir
* @author Philip Weir
* @author Thomas Bruderli
* @author Thomas Bruderli
* @author Aleksander Machniak
* @author Aleksander Machniak
@ -15,8 +15,12 @@
class zipdownload extends rcube_plugin
class zipdownload extends rcube_plugin
{
{
public $task = 'mail';
public $task = 'mail';
private $charset = 'ASCII';
private $charset = 'ASCII';
// RFC4155: mbox date format
const MBOX_DATE_FORMAT = 'D M d H:i:s Y';
/**
/**
* Plugin initialization
* Plugin initialization
*/
*/
@ -225,17 +229,22 @@ class zipdownload extends rcube_plugin
$headers = $imap->get_message_headers($uid);
$headers = $imap->get_message_headers($uid);
if ($mode == 'mbox') {
if ($mode == 'mbox') {
// Sender address
$from = rcube_mime::decode_address_list($headers->from, null, true, $headers->charset, true);
$from = rcube_mime::decode_address_list($headers->from, null, true, $headers->charset, true);
$from = array_shift($from);
$from = array_shift($from);
$from = preg_replace('/\s/', '-', $from);
// Received (internal) date
$date = rcube_utils::anytodatetime($headers->internaldate);
if ($date) {
$date->setTimezone(new DateTimeZone('UTC'));
$date = $date->format(self::MBOX_DATE_FORMAT);
}
// Mbox format header
// Mbox format header (RFC4155)
// @FIXME: \r\n or \n
// @FIXME: date format
$header = sprintf("From %s %s\r\n",
$header = sprintf("From %s %s\r\n",
// replace spaces with hyphens
$from ?: 'MAILER-DAEMON',
$from ? preg_replace('/\s/', '-', $from) : 'MAILER-DAEMON',
$date ?: ''
// internaldate
$headers->internaldate
);
);
fwrite($tmpfp, $header);
fwrite($tmpfp, $header);