forked from extern/egroupware
send OpenPGP/Mime message according to rfc3156, section 4
This commit is contained in:
parent
09fdc8d0fe
commit
38b3122bb8
@ -2159,6 +2159,10 @@ class mail_compose
|
|||||||
*/
|
*/
|
||||||
function createMessage(egw_mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
|
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());
|
//error_log(__METHOD__."(, formDate[filemode]=$_formData[filemode], _autosaving=".array2string($_autosaving).') '.function_backtrace());
|
||||||
$mail_bo = $this->mail_bo;
|
$mail_bo = $this->mail_bo;
|
||||||
$activeMailProfile = emailadmin_account::read($this->mail_bo->profileID);
|
$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()
|
$_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody()
|
||||||
}
|
}
|
||||||
|
elseif ($_formData['mimeType'] == 'openpgp')
|
||||||
|
{
|
||||||
|
$_mailObject->setOpenPgpBody($_formData['body']);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$body = $this->convertHTMLToText($_formData['body'],false);
|
$body = $this->convertHTMLToText($_formData['body'],false);
|
||||||
|
@ -453,7 +453,8 @@ class egw_mailer extends Horde_Mime_Mail
|
|||||||
), array(), true); // true = call all apps
|
), array(), true); // true = call all apps
|
||||||
|
|
||||||
try {
|
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) {
|
catch (Exception $e) {
|
||||||
// in case of errors/exceptions call hook again with previous returned mail_id and error-message to log
|
// 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);
|
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
|
* Clear all non-standard headers
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user