3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Class CRM_Mailing_MailStore_Mbox
21 class CRM_Mailing_MailStore_Mbox
extends CRM_Mailing_MailStore
{
24 * Connect to and lock the supplied file and make sure the two mail dirs exist.
27 * Mbox to operate upon.
29 * @return \CRM_Mailing_MailStore_Mbox
31 public function __construct($file) {
32 $this->_transport
= new ezcMailMboxTransport($file);
33 flock($this->_transport
->fh
, LOCK_EX
);
35 $this->_leftToProcess
= count($this->_transport
->listMessages());
37 $this->_ignored
= $this->maildir(implode(DIRECTORY_SEPARATOR
, [
43 $this->_processed
= $this->maildir(implode(DIRECTORY_SEPARATOR
, [
52 * Empty the mail source (if it was processed fully) and unlock the file.
54 public function __destruct() {
55 if ($this->_leftToProcess
=== 0) {
56 // FIXME: the ftruncate() call does not work for some reason
58 print "trying to delete the mailbox\n";
60 ftruncate($this->_transport
->fh
, 0);
62 flock($this->_transport
->fh
, LOCK_UN
);
66 * Fetch the specified message to the local ignore folder.
69 * Number of the message to fetch.
71 public function markIgnored($nr) {
73 print "copying message $nr to ignored folder\n";
75 $set = new ezcMailStorageSet($this->_transport
->fetchByMessageNr($nr), $this->_ignored
);
76 $parser = new ezcMailParser();
77 $parser->parseMail($set);
78 $this->_leftToProcess
--;
82 * Fetch the specified message to the local processed folder.
85 * Number of the message to fetch.
87 public function markProcessed($nr) {
89 print "copying message $nr to processed folder\n";
91 $set = new ezcMailStorageSet($this->_transport
->fetchByMessageNr($nr), $this->_processed
);
92 $parser = new ezcMailParser();
93 $parser->parseMail($set);
94 $this->_leftToProcess
--;