Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | */ |
33 | ||
28518c90 EM |
34 | /** |
35 | * Class CRM_Mailing_MailStore_Pop3 | |
36 | */ | |
6a488035 TO |
37 | class CRM_Mailing_MailStore_Pop3 extends CRM_Mailing_MailStore { |
38 | ||
39 | /** | |
40 | * Connect to the supplied POP3 server and make sure the two mail dirs exist | |
41 | * | |
90c8230e TO |
42 | * @param string $host |
43 | * Host to connect to. | |
44 | * @param string $username | |
45 | * Authentication username. | |
46 | * @param string $password | |
47 | * Authentication password. | |
48 | * @param bool $ssl | |
49 | * Whether to use POP3 or POP3S. | |
6a488035 | 50 | * |
dd244018 | 51 | * @return \CRM_Mailing_MailStore_Pop3 |
6a488035 | 52 | */ |
00be9182 | 53 | public function __construct($host, $username, $password, $ssl = TRUE) { |
6a488035 TO |
54 | if ($this->_debug) { |
55 | print "connecting to $host and authenticating as $username\n"; | |
56 | } | |
57 | ||
be2fb01f | 58 | $options = ['ssl' => $ssl]; |
6a488035 TO |
59 | $this->_transport = new ezcMailPop3Transport($host, NULL, $options); |
60 | $this->_transport->authenticate($username, $password); | |
61 | ||
be2fb01f | 62 | $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, [ |
7e8c8317 SL |
63 | 'CiviMail.ignored', |
64 | date('Y'), | |
65 | date('m'), | |
66 | date('d'), | |
67 | ])); | |
be2fb01f | 68 | $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, [ |
7e8c8317 SL |
69 | 'CiviMail.processed', |
70 | date('Y'), | |
71 | date('m'), | |
72 | date('d'), | |
73 | ])); | |
6a488035 TO |
74 | } |
75 | ||
76 | /** | |
fe482240 | 77 | * Fetch the specified message to the local ignore folder. |
6a488035 | 78 | * |
90c8230e TO |
79 | * @param int $nr |
80 | * Number of the message to fetch. | |
6a488035 | 81 | */ |
00be9182 | 82 | public function markIgnored($nr) { |
6a488035 TO |
83 | if ($this->_debug) { |
84 | print "fetching message $nr and putting it in the ignored mailbox\n"; | |
85 | } | |
86 | $set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_ignored); | |
acb1052e | 87 | $parser = new ezcMailParser(); |
6a488035 TO |
88 | $parser->parseMail($set); |
89 | $this->_transport->delete($nr); | |
90 | } | |
91 | ||
92 | /** | |
fe482240 | 93 | * Fetch the specified message to the local processed folder. |
6a488035 | 94 | * |
90c8230e TO |
95 | * @param int $nr |
96 | * Number of the message to fetch. | |
6a488035 | 97 | */ |
00be9182 | 98 | public function markProcessed($nr) { |
6a488035 TO |
99 | if ($this->_debug) { |
100 | print "fetching message $nr and putting it in the processed mailbox\n"; | |
101 | } | |
102 | $set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed); | |
acb1052e | 103 | $parser = new ezcMailParser(); |
6a488035 TO |
104 | $parser->parseMail($set); |
105 | $this->_transport->delete($nr); | |
106 | } | |
96025800 | 107 | |
6a488035 | 108 | } |