Fix mail integration fails on SMIME authentication failure.

This commit is contained in:
Hadi Nategh 2018-02-08 15:25:42 +01:00
parent c666b157ba
commit cec3cc2170

View File

@ -293,28 +293,35 @@ class mail_integration {
$mo = mail_bo::getInstance(true,$icServerID); $mo = mail_bo::getInstance(true,$icServerID);
$mo->openConnection(); $mo->openConnection();
$mo->reopen($mailbox); $mo->reopen($mailbox);
$mailcontent = mail_bo::get_mailcontent($mo,$uid,'',$mailbox,null,true,(!($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='text_only'))); try {
// this one adds the mail itself (as message/rfc822 (.eml) file) to the app as additional attachment $mailcontent = mail_bo::get_mailcontent($mo,$uid,'',$mailbox,null,true,(!($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='text_only')));
// this is done to have a simple archive functionality (ToDo: opening .eml in email module) // this one adds the mail itself (as message/rfc822 (.eml) file) to the app as additional attachment
if ($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='add_raw') // this is done to have a simple archive functionality (ToDo: opening .eml in email module)
{ if ($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='add_raw')
$message = $mo->getMessageRawBody($uid, '',$mailbox); {
$headers = $mo->getMessageHeader($uid, '',true,false,$mailbox); $message = $mo->getMessageRawBody($uid, '',$mailbox);
$attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."mail_integrate"); $headers = $mo->getMessageHeader($uid, '',true,false,$mailbox);
$tmpfile = fopen($attachment_file,'w'); $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."mail_integrate");
fwrite($tmpfile,$message); $tmpfile = fopen($attachment_file,'w');
fclose($tmpfile); fwrite($tmpfile,$message);
$size = filesize($attachment_file); fclose($tmpfile);
$mailcontent['attachments'][] = array( $size = filesize($attachment_file);
'name' => mail_bo::clean_subject_for_filename($headers['SUBJECT']).'.eml', $mailcontent['attachments'][] = array(
'mimeType' => 'message/rfc822', 'name' => mail_bo::clean_subject_for_filename($headers['SUBJECT']).'.eml',
'type' => 'message/rfc822', 'mimeType' => 'message/rfc822',
'tmp_name' => $attachment_file, 'type' => 'message/rfc822',
'size' => $size, 'tmp_name' => $attachment_file,
'add_raw' => true 'size' => $size,
); 'add_raw' => true
);
}
$mailcontent['date'] = strtotime($mailcontent['headers']['DATE']);
}
catch (Exception $ex) {
EGroupware\Api\Framework::message(lang('Fetching content of this message failed'.
' because the content of this message seems to be encrypted'.
' and can not be decrypted properly.'),'error');
} }
$mailcontent['date'] = strtotime($mailcontent['headers']['DATE']);
} }
} }