Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | require_once 'ezc/Base/src/ezc_bootstrap.php'; | |
37 | require_once 'ezc/autoload/mail_autoload.php'; | |
28518c90 EM |
38 | |
39 | /** | |
40 | * Class CRM_Mailing_MailStore_Pop3 | |
41 | */ | |
6a488035 TO |
42 | class CRM_Mailing_MailStore_Pop3 extends CRM_Mailing_MailStore { |
43 | ||
44 | /** | |
45 | * Connect to the supplied POP3 server and make sure the two mail dirs exist | |
46 | * | |
90c8230e TO |
47 | * @param string $host |
48 | * Host to connect to. | |
49 | * @param string $username | |
50 | * Authentication username. | |
51 | * @param string $password | |
52 | * Authentication password. | |
53 | * @param bool $ssl | |
54 | * Whether to use POP3 or POP3S. | |
6a488035 | 55 | * |
dd244018 | 56 | * @return \CRM_Mailing_MailStore_Pop3 |
6a488035 | 57 | */ |
00be9182 | 58 | public function __construct($host, $username, $password, $ssl = TRUE) { |
6a488035 TO |
59 | if ($this->_debug) { |
60 | print "connecting to $host and authenticating as $username\n"; | |
61 | } | |
62 | ||
63 | $options = array('ssl' => $ssl); | |
64 | $this->_transport = new ezcMailPop3Transport($host, NULL, $options); | |
65 | $this->_transport->authenticate($username, $password); | |
66 | ||
353ffa53 TO |
67 | $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array( |
68 | 'CiviMail.ignored', | |
69 | date('Y'), | |
70 | date('m'), | |
acb1052e | 71 | date('d'), |
353ffa53 TO |
72 | ))); |
73 | $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array( | |
74 | 'CiviMail.processed', | |
75 | date('Y'), | |
76 | date('m'), | |
acb1052e | 77 | date('d'), |
353ffa53 | 78 | ))); |
6a488035 TO |
79 | } |
80 | ||
81 | /** | |
82 | * Fetch the specified message to the local ignore folder | |
83 | * | |
90c8230e TO |
84 | * @param int $nr |
85 | * Number of the message to fetch. | |
6a488035 TO |
86 | * |
87 | * @return void | |
88 | */ | |
00be9182 | 89 | public function markIgnored($nr) { |
6a488035 TO |
90 | if ($this->_debug) { |
91 | print "fetching message $nr and putting it in the ignored mailbox\n"; | |
92 | } | |
93 | $set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_ignored); | |
acb1052e | 94 | $parser = new ezcMailParser(); |
6a488035 TO |
95 | $parser->parseMail($set); |
96 | $this->_transport->delete($nr); | |
97 | } | |
98 | ||
99 | /** | |
100 | * Fetch the specified message to the local processed folder | |
101 | * | |
90c8230e TO |
102 | * @param int $nr |
103 | * Number of the message to fetch. | |
6a488035 TO |
104 | * |
105 | * @return void | |
106 | */ | |
00be9182 | 107 | public function markProcessed($nr) { |
6a488035 TO |
108 | if ($this->_debug) { |
109 | print "fetching message $nr and putting it in the processed mailbox\n"; | |
110 | } | |
111 | $set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed); | |
acb1052e | 112 | $parser = new ezcMailParser(); |
6a488035 TO |
113 | $parser->parseMail($set); |
114 | $this->_transport->delete($nr); | |
115 | } | |
96025800 | 116 | |
6a488035 | 117 | } |