diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 75b12ed1c1..64b6994e0d 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2159,6 +2159,10 @@ class mail_compose */ function createMessage(egw_mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false) { + if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----') + { + $_formData['mimeType'] = 'openpgp'; + } //error_log(__METHOD__."(, formDate[filemode]=$_formData[filemode], _autosaving=".array2string($_autosaving).') '.function_backtrace()); $mail_bo = $this->mail_bo; $activeMailProfile = emailadmin_account::read($this->mail_bo->profileID); @@ -2292,6 +2296,10 @@ class mail_compose } $_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody() } + elseif ($_formData['mimeType'] == 'openpgp') + { + $_mailObject->setOpenPgpBody($_formData['body']); + } else { $body = $this->convertHTMLToText($_formData['body'],false); diff --git a/phpgwapi/inc/class.egw_mailer.inc.php b/phpgwapi/inc/class.egw_mailer.inc.php index 184e784ab6..b432760586 100644 --- a/phpgwapi/inc/class.egw_mailer.inc.php +++ b/phpgwapi/inc/class.egw_mailer.inc.php @@ -453,7 +453,8 @@ class egw_mailer extends Horde_Mime_Mail ), array(), true); // true = call all apps try { - parent::send($this->account->smtpTransport(), true); // true: keep Message-ID + parent::send($this->account->smtpTransport(), true, // true: keep Message-ID + $this->_body->getType() != 'multipart/encrypted'); // no flowed for encrypted messages } catch (Exception $e) { // in case of errors/exceptions call hook again with previous returned mail_id and error-message to log @@ -632,6 +633,32 @@ class egw_mailer extends Horde_Mime_Mail return parent::addMimePart($part); } + /** + * Sets OpenPGP encrypted body according to rfc3156, section 4 + * + * @param string $body The message content. + * @link https://tools.ietf.org/html/rfc3156#section-4 + */ + public function setOpenPgpBody($body) + { + $this->_body = new Horde_Mime_Part(); + $this->_body->setType('multipart/encrypted'); + $this->_body->setContentTypeParameter('protocol', 'application/pgp-encrypted'); + $this->_body->setContents(''); + + $part1 = new Horde_Mime_Part(); + $part1->setType('application/pgp-encrypted'); + $part1->setContents("Version: 1\r\n", array('encoding' => '7bit')); + $this->_body->addPart($part1); + + $part2 = new Horde_Mime_Part(); + $part2->setType('application/octet-stream'); + $part2->setContents($body, array('encoding' => '7bit')); + $this->_body->addPart($part2); + + $this->_base = null; + } + /** * Clear all non-standard headers *