First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
126
sites/all/modules/civicrm/CRM/Mailing/MailStore/Imap.php
Normal file
126
sites/all/modules/civicrm/CRM/Mailing/MailStore/Imap.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_MailStore_Imap
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Imap extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied IMAP server and make sure the two mailboxes exist.
|
||||
*
|
||||
* @param string $host
|
||||
* Host to connect to.
|
||||
* @param string $username
|
||||
* Authentication username.
|
||||
* @param string $password
|
||||
* Authentication password.
|
||||
* @param bool $ssl
|
||||
* Whether to use IMAP or IMAPS.
|
||||
* @param string $folder
|
||||
* Name of the inbox folder.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Imap
|
||||
*/
|
||||
public function __construct($host, $username, $password, $ssl = TRUE, $folder = 'INBOX') {
|
||||
// default to INBOX if an empty string
|
||||
if (!$folder) {
|
||||
$folder = 'INBOX';
|
||||
}
|
||||
|
||||
if ($this->_debug) {
|
||||
|
||||
print "connecting to $host, authenticating as $username and selecting $folder\n";
|
||||
|
||||
}
|
||||
|
||||
$options = array('ssl' => $ssl, 'uidReferencing' => TRUE);
|
||||
$this->_transport = new ezcMailImapTransport($host, NULL, $options);
|
||||
$this->_transport->authenticate($username, $password);
|
||||
$this->_transport->selectMailbox($folder);
|
||||
|
||||
$this->_ignored = implode($this->_transport->getHierarchyDelimiter(), array($folder, 'CiviMail', 'ignored'));
|
||||
$this->_processed = implode($this->_transport->getHierarchyDelimiter(), array($folder, 'CiviMail', 'processed'));
|
||||
$boxes = $this->_transport->listMailboxes();
|
||||
|
||||
if ($this->_debug) {
|
||||
print 'mailboxes found: ' . implode(', ', $boxes) . "\n";
|
||||
}
|
||||
|
||||
if (!in_array(strtolower($this->_ignored), array_map('strtolower', $boxes))) {
|
||||
$this->_transport->createMailbox($this->_ignored);
|
||||
}
|
||||
|
||||
if (!in_array(strtolower($this->_processed), array_map('strtolower', $boxes))) {
|
||||
$this->_transport->createMailbox($this->_processed);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expunge the messages marked for deletion, CRM-7356
|
||||
*/
|
||||
public function expunge() {
|
||||
$this->_transport->expunge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the specified message to the ignored folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to move.
|
||||
*/
|
||||
public function markIgnored($nr) {
|
||||
if ($this->_debug) {
|
||||
print "setting $nr as seen and moving it to the ignored mailbox\n";
|
||||
}
|
||||
$this->_transport->setFlag($nr, 'SEEN');
|
||||
$this->_transport->copyMessages($nr, $this->_ignored);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the specified message to the processed folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to move.
|
||||
*/
|
||||
public function markProcessed($nr) {
|
||||
if ($this->_debug) {
|
||||
print "setting $nr as seen and moving it to the processed mailbox\n";
|
||||
}
|
||||
$this->_transport->setFlag($nr, 'SEEN');
|
||||
$this->_transport->copyMessages($nr, $this->_processed);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
}
|
158
sites/all/modules/civicrm/CRM/Mailing/MailStore/Localdir.php
Normal file
158
sites/all/modules/civicrm/CRM/Mailing/MailStore/Localdir.php
Normal file
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_MailStore_Localdir
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Localdir extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied dir and make sure the two mail dirs exist.
|
||||
*
|
||||
* @param string $dir
|
||||
* Dir to operate upon.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Localdir
|
||||
*/
|
||||
public function __construct($dir) {
|
||||
$this->_dir = $dir;
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next X messages from the mail store.
|
||||
* FIXME: in CiviCRM 2.2 this always returns all the emails
|
||||
*
|
||||
* @param int $count
|
||||
* Number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all).
|
||||
*
|
||||
* @return array
|
||||
* array of ezcMail objects
|
||||
*/
|
||||
public function fetchNext($count = 0) {
|
||||
$mails = array();
|
||||
$path = rtrim($this->_dir, DIRECTORY_SEPARATOR);
|
||||
|
||||
if ($this->_debug) {
|
||||
|
||||
print "fetching $count messages\n";
|
||||
|
||||
}
|
||||
|
||||
$directory = new DirectoryIterator($path);
|
||||
foreach ($directory as $entry) {
|
||||
if ($entry->isDot()) {
|
||||
continue;
|
||||
}
|
||||
if (count($mails) >= $count) {
|
||||
break;
|
||||
}
|
||||
|
||||
$file = $path . DIRECTORY_SEPARATOR . $entry->getFilename();
|
||||
if ($this->_debug) {
|
||||
print "retrieving message $file\n";
|
||||
}
|
||||
|
||||
$set = new ezcMailFileSet(array($file));
|
||||
$parser = new ezcMailParser();
|
||||
// set property text attachment as file CRM-5408
|
||||
$parser->options->parseTextAttachmentsAsFiles = TRUE;
|
||||
|
||||
$mail = $parser->parseMail($set);
|
||||
|
||||
if (!$mail) {
|
||||
return CRM_Core_Error::createAPIError(ts('%1 could not be parsed',
|
||||
array(1 => $file)
|
||||
));
|
||||
}
|
||||
$mails[$file] = $mail[0];
|
||||
}
|
||||
|
||||
if ($this->_debug && (count($mails) <= 0)) {
|
||||
|
||||
print "No messages found\n";
|
||||
|
||||
}
|
||||
|
||||
return $mails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markIgnored($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to ignored folder\n";
|
||||
}
|
||||
$target = $this->_ignored . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markProcessed($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to processed folder\n";
|
||||
}
|
||||
$target = $this->_processed . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
141
sites/all/modules/civicrm/CRM/Mailing/MailStore/Maildir.php
Normal file
141
sites/all/modules/civicrm/CRM/Mailing/MailStore/Maildir.php
Normal file
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_MailStore_Maildir
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Maildir extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied dir and make sure the two mail dirs exist.
|
||||
*
|
||||
* @param string $dir
|
||||
* Dir to operate upon.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Maildir
|
||||
*/
|
||||
public function __construct($dir) {
|
||||
$this->_dir = $dir;
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next X messages from the mail store.
|
||||
* FIXME: in CiviCRM 2.2 this always returns all the emails
|
||||
*
|
||||
* @param int $count
|
||||
* Number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all).
|
||||
*
|
||||
* @return array
|
||||
* array of ezcMail objects
|
||||
*/
|
||||
public function fetchNext($count = 0) {
|
||||
$mails = array();
|
||||
$parser = new ezcMailParser();
|
||||
// set property text attachment as file CRM-5408
|
||||
$parser->options->parseTextAttachmentsAsFiles = TRUE;
|
||||
|
||||
foreach (array(
|
||||
'cur',
|
||||
'new',
|
||||
) as $subdir) {
|
||||
$dir = $this->_dir . DIRECTORY_SEPARATOR . $subdir;
|
||||
foreach (scandir($dir) as $file) {
|
||||
if ($file == '.' or $file == '..') {
|
||||
continue;
|
||||
}
|
||||
$path = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
if ($this->_debug) {
|
||||
|
||||
print "retrieving message $path\n";
|
||||
|
||||
}
|
||||
|
||||
$set = new ezcMailFileSet(array($path));
|
||||
$single = $parser->parseMail($set);
|
||||
$mails[$path] = $single[0];
|
||||
}
|
||||
}
|
||||
return $mails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markIgnored($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to ignored folder\n";
|
||||
}
|
||||
$target = $this->_ignored . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $file
|
||||
* File location of the message to fetch.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function markProcessed($file) {
|
||||
if ($this->_debug) {
|
||||
print "moving $file to processed folder\n";
|
||||
}
|
||||
$target = $this->_processed . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (!rename($file, $target)) {
|
||||
throw new Exception("Could not rename $file to $target");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
113
sites/all/modules/civicrm/CRM/Mailing/MailStore/Mbox.php
Normal file
113
sites/all/modules/civicrm/CRM/Mailing/MailStore/Mbox.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_MailStore_Mbox
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Mbox extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to and lock the supplied file and make sure the two mail dirs exist.
|
||||
*
|
||||
* @param string $file
|
||||
* Mbox to operate upon.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Mbox
|
||||
*/
|
||||
public function __construct($file) {
|
||||
$this->_transport = new ezcMailMboxTransport($file);
|
||||
flock($this->_transport->fh, LOCK_EX);
|
||||
|
||||
$this->_leftToProcess = count($this->_transport->listMessages());
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the mail source (if it was processed fully) and unlock the file.
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ($this->_leftToProcess === 0) {
|
||||
// FIXME: the ftruncate() call does not work for some reason
|
||||
if ($this->_debug) {
|
||||
print "trying to delete the mailbox\n";
|
||||
}
|
||||
ftruncate($this->_transport->fh, 0);
|
||||
}
|
||||
flock($this->_transport->fh, LOCK_UN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markIgnored($nr) {
|
||||
if ($this->_debug) {
|
||||
print "copying message $nr to ignored folder\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_ignored);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_leftToProcess--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markProcessed($nr) {
|
||||
if ($this->_debug) {
|
||||
print "copying message $nr to processed folder\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_leftToProcess--;
|
||||
}
|
||||
|
||||
}
|
108
sites/all/modules/civicrm/CRM/Mailing/MailStore/Pop3.php
Normal file
108
sites/all/modules/civicrm/CRM/Mailing/MailStore/Pop3.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Mailing_MailStore_Pop3
|
||||
*/
|
||||
class CRM_Mailing_MailStore_Pop3 extends CRM_Mailing_MailStore {
|
||||
|
||||
/**
|
||||
* Connect to the supplied POP3 server and make sure the two mail dirs exist
|
||||
*
|
||||
* @param string $host
|
||||
* Host to connect to.
|
||||
* @param string $username
|
||||
* Authentication username.
|
||||
* @param string $password
|
||||
* Authentication password.
|
||||
* @param bool $ssl
|
||||
* Whether to use POP3 or POP3S.
|
||||
*
|
||||
* @return \CRM_Mailing_MailStore_Pop3
|
||||
*/
|
||||
public function __construct($host, $username, $password, $ssl = TRUE) {
|
||||
if ($this->_debug) {
|
||||
print "connecting to $host and authenticating as $username\n";
|
||||
}
|
||||
|
||||
$options = array('ssl' => $ssl);
|
||||
$this->_transport = new ezcMailPop3Transport($host, NULL, $options);
|
||||
$this->_transport->authenticate($username, $password);
|
||||
|
||||
$this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.ignored',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
$this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array(
|
||||
'CiviMail.processed',
|
||||
date('Y'),
|
||||
date('m'),
|
||||
date('d'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local ignore folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markIgnored($nr) {
|
||||
if ($this->_debug) {
|
||||
print "fetching message $nr and putting it in the ignored mailbox\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_ignored);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the specified message to the local processed folder.
|
||||
*
|
||||
* @param int $nr
|
||||
* Number of the message to fetch.
|
||||
*/
|
||||
public function markProcessed($nr) {
|
||||
if ($this->_debug) {
|
||||
print "fetching message $nr and putting it in the processed mailbox\n";
|
||||
}
|
||||
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed);
|
||||
$parser = new ezcMailParser();
|
||||
$parser->parseMail($set);
|
||||
$this->_transport->delete($nr);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue