From 4cd087ea2eb8d1dbc8a063b41cffcd5df35d7df6 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sun, 13 Sep 2015 08:50:16 -0400 Subject: [PATCH] Fixed mailvelope-generated messages structure (required Mail_Mime-1.10.0) --- composer.json-dist | 2 +- program/steps/mail/sendmail.inc | 42 ++++++++++++++---------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/composer.json-dist b/composer.json-dist index b6d4fba..09e8b58 100644 --- a/composer.json-dist +++ b/composer.json-dist @@ -25,7 +25,7 @@ "roundcube/plugin-installer": "~0.1.6", "pear-pear.php.net/auth_sasl": "~1.0.6", "pear-pear.php.net/net_idna2": "~0.1.1", - "pear-pear.php.net/mail_mime": "~1.9.0", + "pear-pear.php.net/mail_mime": "~1.10.0", "pear-pear.php.net/net_smtp": "~1.7.1", "pear-pear.php.net/crypt_gpg": "*", "roundcube/net_sieve": "~1.5.0" diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index e58dce3..f797e2d 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -247,9 +247,9 @@ $message_body = rcube_utils::get_input_value('_message', rcube_utils::INPUT_POST, TRUE, $message_charset); if (isset($_POST['_pgpmime'])) { - $pgp_mime = rcube_utils::get_input_value('_pgpmime', rcube_utils::INPUT_POST); - $message_body = 'This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)'; - $isHtml = false; + $pgp_mime = rcube_utils::get_input_value('_pgpmime', rcube_utils::INPUT_POST); + $isHtml = false; + $message_body = ''; // clear unencrypted attachments foreach ((array) $COMPOSE['attachments'] as $attach) { @@ -490,33 +490,19 @@ // compose PGP/Mime message if ($pgp_mime) { - $MAIL_MIME->addAttachment( - 'Version: 1', - 'application/pgp-encrypted', - 'version.txt', // required by Mail_mime::addAttachment() - false, - '8bit', - '', // $disposition - '', // $charset - '', // $language - '', // $location - null, // $n_encoding - null, // $f_encoding - 'PGP/MIME version identification' - ); + $MAIL_MIME->addAttachment(new Mail_mimePart('Version: 1', array( + 'content_type' => 'application/pgp-encrypted', + 'description' => 'PGP/MIME version identification', + ))); - // @TODO: remove filename out of the version part, required Mail_Mime changes + $MAIL_MIME->addAttachment(new Mail_mimePart($pgp_mime, array( + 'content_type' => 'application/octet-stream', + 'filename' => 'encrypted.asc', + 'disposition' => 'inline', + ))); - $MAIL_MIME->addAttachment( - $pgp_mime, - 'application/octet-stream', - 'encrypted.asc', - false, - '8bit', - 'inline' - ); - - $MAIL_MIME->setContentType('multipart/encrypted', array('protocol' => "application/pgp-encrypted")); + $MAIL_MIME->setContentType('multipart/encrypted', array('protocol' => 'application/pgp-encrypted')); + $MAIL_MIME->setParam('preamble', 'This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)'); } // encoding settings for mail composing -- Gitblit v1.9.1