protected function _saveToSentMail(Horde_Mime_Headers $headers, Horde_Mime_Part $save_msg, Horde_Mail_Rfc822_List $recips, $opts)
{
global $injector, $language, $notification, $prefs;
if (empty($opts['sent_mail']) || $prefs->isLocked('save_sent_mail') && !$prefs->getValue('save_sent_mail') || !$prefs->isLocked('save_sent_mail') && empty($opts['save_sent'])) {
return;
}
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
/* If message contains EAI addresses, we need to verify that the IMAP
* server can handle this data in order to save. */
foreach ($recips as $val) {
if ($val->eai) {
if ($imp_imap->client_ob->capability->query('UTF8', 'ACCEPT')) {
break;
}
$notification->push(sprintf(_("Message sent successfully, but not saved to %s."), $sent_mail->display));
return;
}
}
/* Strip attachments if requested. */
if (!empty($opts['strip_attachments'])) {
$save_msg->buildMimeIds();
/* Don't strip any part if this is a text message with both
* plaintext and HTML representation, or a signed or encrypted
* message. */
if ($save_msg->getType() != 'multipart/alternative' && $save_msg->getType() != 'multipart/encrypted' && $save_msg->getType() != 'multipart/signed') {
for ($i = 2;; ++$i) {
if (!($oldPart = $save_msg[$i])) {
break;
}
$replace_part = new Horde_Mime_Part();
$replace_part->setType('text/plain');
$replace_part->setCharset($this->charset);
$replace_part->setLanguage($language);
$replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]');
$save_msg[$i] = $replace_part;
}
}
}
/* Generate the message string. */
$fcc = $save_msg->toString(array('defserver' => $imp_imap->config->maildomain, 'headers' => $headers, 'stream' => true));
/* Make sure sent mailbox is created. */
$sent_mail = IMP_Mailbox::get($opts['sent_mail']);
$sent_mail->create();
$flags = array(Horde_Imap_Client::FLAG_SEEN, Horde_Imap_Client::FLAG_MDNSENT);
try {
$imp_imap->append($sent_mail, array(array('data' => $fcc, 'flags' => $flags)));
} catch (IMP_Imap_Exception $e) {
$notification->push(sprintf(_("Message sent successfully, but not saved to %s."), $sent_mail->display));
}
}