Merge pull request #23815 from seamuslee001/date_second_customformat
[civicrm-core.git] / CRM / Mailing / MailStore / Pop3.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
28518c90
EM
18/**
19 * Class CRM_Mailing_MailStore_Pop3
20 */
6a488035
TO
21class CRM_Mailing_MailStore_Pop3 extends CRM_Mailing_MailStore {
22
23 /**
24 * Connect to the supplied POP3 server and make sure the two mail dirs exist
25 *
90c8230e
TO
26 * @param string $host
27 * Host to connect to.
28 * @param string $username
29 * Authentication username.
30 * @param string $password
31 * Authentication password.
32 * @param bool $ssl
33 * Whether to use POP3 or POP3S.
6a488035 34 *
dd244018 35 * @return \CRM_Mailing_MailStore_Pop3
6a488035 36 */
00be9182 37 public function __construct($host, $username, $password, $ssl = TRUE) {
6a488035
TO
38 if ($this->_debug) {
39 print "connecting to $host and authenticating as $username\n";
40 }
41
be2fb01f 42 $options = ['ssl' => $ssl];
6a488035
TO
43 $this->_transport = new ezcMailPop3Transport($host, NULL, $options);
44 $this->_transport->authenticate($username, $password);
45
be2fb01f 46 $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, [
7e8c8317
SL
47 'CiviMail.ignored',
48 date('Y'),
49 date('m'),
50 date('d'),
51 ]));
be2fb01f 52 $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, [
7e8c8317
SL
53 'CiviMail.processed',
54 date('Y'),
55 date('m'),
56 date('d'),
57 ]));
6a488035
TO
58 }
59
60 /**
fe482240 61 * Fetch the specified message to the local ignore folder.
6a488035 62 *
90c8230e
TO
63 * @param int $nr
64 * Number of the message to fetch.
6a488035 65 */
00be9182 66 public function markIgnored($nr) {
6a488035
TO
67 if ($this->_debug) {
68 print "fetching message $nr and putting it in the ignored mailbox\n";
69 }
70 $set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_ignored);
acb1052e 71 $parser = new ezcMailParser();
6a488035
TO
72 $parser->parseMail($set);
73 $this->_transport->delete($nr);
74 }
75
76 /**
fe482240 77 * Fetch the specified message to the local processed folder.
6a488035 78 *
90c8230e
TO
79 * @param int $nr
80 * Number of the message to fetch.
6a488035 81 */
00be9182 82 public function markProcessed($nr) {
6a488035
TO
83 if ($this->_debug) {
84 print "fetching message $nr and putting it in the processed mailbox\n";
85 }
86 $set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed);
acb1052e 87 $parser = new ezcMailParser();
6a488035
TO
88 $parser->parseMail($set);
89 $this->_transport->delete($nr);
90 }
96025800 91
6a488035 92}