Batch handling of moving messages should speed up production thing
This commit is contained in:
parent
daa4abf828
commit
08cba65fd6
44
vendors/shells/vault.php
vendored
44
vendors/shells/vault.php
vendored
|
|
@ -10,8 +10,8 @@ class VaultShell extends Shell {
|
||||||
var $uses = array('Enquiry', 'Email', 'EmailAttachment');
|
var $uses = array('Enquiry', 'Email', 'EmailAttachment');
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|
||||||
/******************************************************
|
/******************************************************
|
||||||
* Config Variables
|
* Config Variables
|
||||||
* *****************************************************/
|
* *****************************************************/
|
||||||
$testing = 0; //Whether to actually move the emails. 1=test, 0=production
|
$testing = 0; //Whether to actually move the emails. 1=test, 0=production
|
||||||
|
|
@ -32,7 +32,7 @@ class VaultShell extends Shell {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$mbox = imap_open("{192.168.0.8:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
|
$mbox = imap_open("{192.168.0.8:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,6 +57,8 @@ class VaultShell extends Shell {
|
||||||
$enquiryList[$enqNumber] = $id;
|
$enquiryList[$enqNumber] = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$storedArray = array();
|
||||||
|
$discardArray = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -154,9 +156,9 @@ class VaultShell extends Shell {
|
||||||
}
|
}
|
||||||
echo "Email stored in the DB under enquiry ID".$enqID." Will be moved to the stored folder\n";
|
echo "Email stored in the DB under enquiry ID".$enqID." Will be moved to the stored folder\n";
|
||||||
|
|
||||||
if($testing == 0) {
|
$storedArray[] = $i;
|
||||||
imap_mail_move($mbox, $i, 'INBOX/Stored');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo 'Unable to save the Email\n';
|
echo 'Unable to save the Email\n';
|
||||||
|
|
@ -165,19 +167,37 @@ class VaultShell extends Shell {
|
||||||
echo "Unable to find either HTML or Plaintext body to this email. Ignoring it";
|
echo "Unable to find either HTML or Plaintext body to this email. Ignoring it";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Can't find a valid-looking CMC Enquiry Number. Move the message to the discarded folder
|
/* Can't find a valid-looking CMC Enquiry Number. Move the message to the discarded folder
|
||||||
* I may change this to simply delete the emails. This will do for now, but it's doubling up on the storage for useless files.
|
* I may change this to simply delete the emails. This will do for now, but it's doubling up on the storage for useless files.
|
||||||
* */
|
* */
|
||||||
|
|
||||||
if($testing == 0 ) {
|
$discardArray[] = $i;
|
||||||
imap_mail_move($mbox, $i, 'INBOX/Discarded');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Finished working with the IMAP server. Make the changes and close the connection */
|
/* Finished working with the IMAP server. Make the changes and close the connection */
|
||||||
|
|
||||||
|
if($testing == 0) {
|
||||||
|
|
||||||
|
reset($discardArray);
|
||||||
|
reset($storedArray);
|
||||||
|
|
||||||
|
$storeSet = implode(",", $storedArray);
|
||||||
|
$discardSet = implode(",",$discardArray);
|
||||||
|
|
||||||
|
echo "Tidying up now. Moving messages to Stored or Discarded\n";
|
||||||
|
|
||||||
|
imap_mail_move($mbox, $storeSet, 'INBOX/Stored');
|
||||||
|
imap_mail_move($mbox, $discardSet, 'INBOX/Discarded');
|
||||||
|
}
|
||||||
|
|
||||||
imap_expunge($mbox);
|
imap_expunge($mbox);
|
||||||
imap_close($mbox);
|
imap_close($mbox);
|
||||||
}
|
}
|
||||||
|
|
@ -233,8 +253,8 @@ class VaultShell extends Shell {
|
||||||
|
|
||||||
$subject = $headers->subject;
|
$subject = $headers->subject;
|
||||||
//$subject = iconv_mime_decode($subject, 0, "ISO-8859-1//IGNORE");
|
//$subject = iconv_mime_decode($subject, 0, "ISO-8859-1//IGNORE");
|
||||||
// $subject = mb_convert_encoding($subject, "ISO-8859-1");
|
// $subject = mb_convert_encoding($subject, "ISO-8859-1");
|
||||||
// $subject = mb_convert_encoding($subject, "UTF-8");
|
// $subject = mb_convert_encoding($subject, "UTF-8");
|
||||||
$subject = mb_decode_mimeheader($subject);
|
$subject = mb_decode_mimeheader($subject);
|
||||||
|
|
||||||
$date = $headers->date;
|
$date = $headers->date;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue