mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:41:59 +01:00
added an option to restore message as rfc822 attachment
This commit is contained in:
parent
35aeb0463b
commit
0517c131b0
@ -139,6 +139,7 @@ $config['SEARCH_RESULT_CHECKBOX_CHECKED'] = 0;
|
||||
$config['HELPER_URL'] = '';
|
||||
$config['ENABLE_SYSLOG'] = 1;
|
||||
$config['REWRITE_MESSAGE_ID'] = 0;
|
||||
$config['RESTORE_EMAILS_AS_ATTACHMENT'] = 0;
|
||||
$config['RESTRICTED_AUDITOR'] = 0;
|
||||
|
||||
$config['SHOW_ENVELOPE_JOURNAL'] = 0;
|
||||
|
@ -90,10 +90,17 @@ class ControllerMessageBulkrestore extends Controller {
|
||||
}
|
||||
else {
|
||||
|
||||
if(RESTORE_EMAILS_AS_ATTACHMENT == 1) {
|
||||
$msg = $this->model_mail_mail->message_as_rfc822_attachment($piler_id, $msg, $rcpt[0]);
|
||||
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, $msg);
|
||||
}
|
||||
else {
|
||||
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
|
||||
"Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $msg );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($x == 1) { $this->data['restored']++; }
|
||||
}
|
||||
}
|
||||
|
@ -82,10 +82,17 @@ class ControllerMessageRestore extends Controller {
|
||||
}
|
||||
else {
|
||||
|
||||
if(RESTORE_EMAILS_AS_ATTACHMENT == 1) {
|
||||
$msg = $this->model_mail_mail->message_as_rfc822_attachment($this->data['id'], $msg, $rcpt[0]);
|
||||
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, $msg);
|
||||
}
|
||||
else {
|
||||
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
|
||||
"Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $msg );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,46 @@ class ModelMailMail extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function message_as_rfc822_attachment($piler_id = '', $msg = '', $rcpt = '') {
|
||||
if($piler_id == '' || $msg == '' || $rcpt == '') { return ''; }
|
||||
|
||||
$boundary = generate_random_string(24);
|
||||
|
||||
$hdr = substr($msg, 0, 8192);
|
||||
$subject = "";
|
||||
|
||||
$s = strstr($hdr, "Subject:");
|
||||
if($s) {
|
||||
$l1 = strlen($s);
|
||||
$l2 = strlen(strstr($s, "\n"));
|
||||
if($l1 > $l2 + 10) {
|
||||
$subject = substr($s, 0, $l1 - $l2) . EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$s = "";
|
||||
$s .= "Received: by piler" . EOL . PILER_HEADER_FIELD . $piler_id . EOL;
|
||||
$s .= "Date: " . date("r") . EOL;
|
||||
$s .= "Message-ID: <" . generate_random_string(25) . '@' . SITE_NAME . ">" . EOL;
|
||||
$s .= "From: " . SMTP_FROMADDR . EOL;
|
||||
$s .= "To: " . $rcpt . EOL;
|
||||
|
||||
if($subject) { $s .= $subject; }
|
||||
else { $s .= "Subject: Retrieved message from the email archive" . EOL; }
|
||||
|
||||
$s .= "MIME-Version: 1.0" . EOL;
|
||||
$s .= "Content-Type: multipart/mixed; boundary=\"$boundary\"" . EOL . EOL . EOL;
|
||||
$s .= "--$boundary" . EOL;
|
||||
$s .= "Content-Type: message/rfc822; name=\"" . $piler_id . "\"" . EOL;
|
||||
$s .= "Content-Disposition: attachment; filename=\"" . $piler_id . "\"" . EOL . EOL;
|
||||
$s .= $msg . EOL;
|
||||
$s .= "--$boundary" . EOL;
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
public function connect_imap() {
|
||||
$this->imap = new Zend_Mail_Protocol_Imap(IMAP_HOST, IMAP_PORT, IMAP_SSL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user