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_Maildir
21 class CRM_Mailing_MailStore_Maildir
extends CRM_Mailing_MailStore
{
24 * Connect to the supplied dir and make sure the two mail dirs exist.
27 * Dir to operate upon.
29 * @return \CRM_Mailing_MailStore_Maildir
31 public function __construct($dir) {
34 $this->_ignored
= $this->maildir(implode(DIRECTORY_SEPARATOR
, [
40 $this->_processed
= $this->maildir(implode(DIRECTORY_SEPARATOR
, [
49 * Return the next X messages from the mail store.
50 * FIXME: in CiviCRM 2.2 this always returns all the emails
53 * Number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all).
56 * array of ezcMail objects
58 public function fetchNext($count = 0) {
60 $parser = new ezcMailParser();
61 // set property text attachment as file CRM-5408
62 $parser->options
->parseTextAttachmentsAsFiles
= TRUE;
68 $dir = $this->_dir
. DIRECTORY_SEPARATOR
. $subdir;
69 foreach (scandir($dir) as $file) {
70 if ($file == '.' or $file == '..') {
73 $path = $dir . DIRECTORY_SEPARATOR
. $file;
77 print "retrieving message $path\n";
81 $set = new ezcMailFileSet([$path]);
82 $single = $parser->parseMail($set);
83 $mails[$path] = $single[0];
90 * Fetch the specified message to the local ignore folder.
93 * File location of the message to fetch.
97 public function markIgnored($file) {
99 print "moving $file to ignored folder\n";
101 $target = $this->_ignored
. DIRECTORY_SEPARATOR
. basename($file);
102 if (!rename($file, $target)) {
103 throw new Exception("Could not rename $file to $target");
108 * Fetch the specified message to the local processed folder.
111 * File location of the message to fetch.
115 public function markProcessed($file) {
117 print "moving $file to processed folder\n";
119 $target = $this->_processed
. DIRECTORY_SEPARATOR
. basename($file);
120 if (!rename($file, $target)) {
121 throw new Exception("Could not rename $file to $target");