PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Libraries/Imap2/HeaderInfo.php +0 -131 11.0.1 → 11.1.1 View file →
@@ -1,131 +1,0 @@
1 -<?php
2 -
3 -/*
4 - * This file is part of the PHP IMAP2 package.
5 - *
6 - * (c) Francesco Bianco <[email protected]>
7 - *
8 - * For the full copyright and license information, please view the LICENSE
9 - * file that was distributed with this source code.
10 - */
11 -
12 -namespace AcyMailing\Libraries\Imap2;
13 -
14 -class HeaderInfo
15 -{
16 - public static function fromMessage($message, $defaultHost)
17 - {
18 - #file_put_contents('t3.json', json_encode($message, JSON_PRETTY_PRINT));
19 -
20 - $to = Functions::writeAddressFromEnvelope($message->envelope[5]);
21 - $cc = Functions::writeAddressFromEnvelope($message->envelope[6]);
22 - $from = Functions::writeAddressFromEnvelope($message->envelope[2]);
23 - $sender = Functions::writeAddressFromEnvelope($message->envelope[3]);
24 -
25 - if (empty($message->replyto)) {
26 - $replyTo = $from;
27 - } else {
28 - $replyTo = Functions::writeAddressFromEnvelope($message->envelope[4]);
29 - }
30 -
31 - $headerInfo = [
32 - 'date' => $message->envelope[0],
33 - 'Date' => $message->envelope[0],
34 - 'subject' => $message->envelope[1],
35 - 'Subject' => $message->envelope[1],
36 - 'in_reply_to' => $message->envelope[8],
37 - 'message_id' => $message->envelope[9],
38 - 'references' => $message->references,
39 - 'toaddress' => $to,
40 - 'to' => self::parseAddressList($to, $defaultHost),
41 - 'fromaddress' => $from,
42 - 'from' => self::parseAddressList($from, $defaultHost),
43 - 'ccaddress' => $cc,
44 - 'cc' => self::parseAddressList($cc, $defaultHost),
45 - 'reply_toaddress' => $replyTo,
46 - 'reply_to' => self::parseAddressList($replyTo, $defaultHost),
47 - 'senderaddress' => $sender,
48 - 'sender' => self::parseAddressList($sender, $defaultHost),
49 - 'Recent' => ' ',
50 - 'Unseen' => isset($message->flags['SEEN']) && $message->flags['SEEN'] ? ' ' : 'U',
51 - 'Flagged' => empty($message->flags['FLAGGED']) ? ' ' : 'F',
52 - 'Answered' => empty($message->flags['ANSWERED']) ? ' ' : 'A',
53 - 'Deleted' => empty($message->flags['DELETED']) ? ' ' : 'X',
54 - 'Draft' => empty($message->flags['DRAFT']) ? ' ' : 'D',
55 - 'Msgno' => str_pad($message->id, 4, ' ', STR_PAD_LEFT),
56 - 'MailDate' => self::sanitizeMailDate($message->internaldate),
57 - 'Size' => strval($message->size),
58 - 'udate' => strtotime($message->internaldate),
59 - ];
60 -
61 - if (empty($headerInfo['subject'])) {
62 - unset($headerInfo['subject']);
63 - unset($headerInfo['Subject']);
64 - }
65 -
66 - if (empty($headerInfo['in_reply_to'])) {
67 - unset($headerInfo['in_reply_to']);
68 - }
69 -
70 - if (empty($headerInfo['references'])) {
71 - unset($headerInfo['references']);
72 - }
73 -
74 - if (empty($headerInfo['to'])) {
75 - unset($headerInfo['toaddress']);
76 - unset($headerInfo['to']);
77 - }
78 -
79 - if (empty($headerInfo['cc'])) {
80 - unset($headerInfo['ccaddress']);
81 - unset($headerInfo['cc']);
82 - }
83 -
84 - return (object)$headerInfo;
85 - }
86 -
87 - protected static function parseAddressList($address, $defaultHost)
88 - {
89 - if (empty($address)) {
90 - return [];
91 - }
92 -
93 - $host = empty($defaultHost) ? '' : $defaultHost;
94 - $addressList = imap_rfc822_parse_adrlist($address, $host);
95 - $customAddressList = [];
96 -
97 - foreach ($addressList as $objectEntry) {
98 - $addressEntry = (object)[
99 - 'personal' => $objectEntry->personal ?? null,
100 - 'mailbox' => @$objectEntry->mailbox,
101 - 'host' => @$objectEntry->host,
102 - ];
103 -
104 - if (empty($addressEntry->personal)) {
105 - unset($addressEntry->personal);
106 - }
107 -
108 - if (empty($addressEntry->host)) {
109 - unset($addressEntry->host);
110 - }
111 -
112 - if (empty($addressEntry->mailbox)) {
113 - continue;
114 - }
115 -
116 - $customAddressList[] = $addressEntry;
117 - }
118 -
119 - return $customAddressList;
120 - }
121 -
122 - public static function sanitizeMailDate($mailDate)
123 - {
124 - if ($mailDate[0] == '0') {
125 - $mailDate = ' '.substr($mailDate, 1);
126 - }
127 -
128 - return $mailDate;
129 - }
130 -}
131 -