Version Description
(2020-02-18) = * Fix: signature stripping in html emails was failing sometimes
Download this release
Release Info
Developer | WayneAllen |
Plugin | Postie |
Version | 1.9.42 |
Comparing to | |
See all releases |
Code changes from version 1.9.40 to 1.9.42
- deploy/_deploy.txt +0 -1
- docs/Changes.txt +7 -0
- docs/Postie.txt +1 -1
- docs/TODO.txt +0 -1
- lib/fMailbox.php +1 -2
- postie-filters.php +15 -9
- postie-tags.php +1 -1
- postie.class.php +61 -60
- postie.php +6 -3
- readme.txt +9 -1
deploy/_deploy.txt
CHANGED
@@ -5,7 +5,6 @@ update date in docs\Changes.txt
|
|
5 |
update Upgrade Notice in docs\Changes.txt
|
6 |
update version number in docs\Postie.txt
|
7 |
update version number in postie.php comment
|
8 |
-
update version number in postie.php code
|
9 |
|
10 |
run deploy.cmd
|
11 |
commit
|
5 |
update Upgrade Notice in docs\Changes.txt
|
6 |
update version number in docs\Postie.txt
|
7 |
update version number in postie.php comment
|
|
|
8 |
|
9 |
run deploy.cmd
|
10 |
commit
|
docs/Changes.txt
CHANGED
@@ -35,6 +35,13 @@ All script, style and body tags are stripped from html emails.
|
|
35 |
Attachments are now processed in the order they were attached.
|
36 |
|
37 |
== CHANGELOG ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
= 1.9.40 (2019-11-13) =
|
39 |
* Fix issue with class-oembed.php upgrade
|
40 |
|
35 |
Attachments are now processed in the order they were attached.
|
36 |
|
37 |
== CHANGELOG ==
|
38 |
+
= 1.9.42 (2020-02-18) =
|
39 |
+
* Fix: signature stripping in html emails was failing sometimes
|
40 |
+
|
41 |
+
= 1.9.41 (2020-02-01) =
|
42 |
+
* Fix: different regex approach for html vs plain
|
43 |
+
* Only process 1 email at a time
|
44 |
+
|
45 |
= 1.9.40 (2019-11-13) =
|
46 |
* Fix issue with class-oembed.php upgrade
|
47 |
|
docs/Postie.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: e-mail, email, post-by-email
|
|
7 |
Requires PHP: 5.3
|
8 |
Requires at least: 4.0
|
9 |
Tested up to: 5.3
|
10 |
-
Stable tag: 1.9.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
7 |
Requires PHP: 5.3
|
8 |
Requires at least: 4.0
|
9 |
Tested up to: 5.3
|
10 |
+
Stable tag: 1.9.42
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
docs/TODO.txt
CHANGED
@@ -13,7 +13,6 @@ Comment not being created when subject contains fomat or type. I.e. re: image//I
|
|
13 |
|
14 |
Other
|
15 |
Google Sign-In https://developers.google.com/identity/sign-in/web/sign-in
|
16 |
-
Process single email at a time and don't delete unless successful
|
17 |
detect links to embeddable content and remove anchor tag <a href="https://youtube.com?...">https://youtube.com</a>
|
18 |
Add default comment status (like post status) wp_set_comment_status
|
19 |
Test server port combination by opening a socket connection to see if any service responds. (via ajax call)
|
13 |
|
14 |
Other
|
15 |
Google Sign-In https://developers.google.com/identity/sign-in/web/sign-in
|
|
|
16 |
detect links to embeddable content and remove anchor tag <a href="https://youtube.com?...">https://youtube.com</a>
|
17 |
Add default comment status (like post status) wp_set_comment_status
|
18 |
Test server port combination by opening a socket connection to see if any service responds. (via ajax call)
|
lib/fMailbox.php
CHANGED
@@ -506,7 +506,7 @@ class fMailbox {
|
|
506 |
*/
|
507 |
static private function parseEmail($string) {
|
508 |
$email_regex = '((?:[^\x00-\x20\(\)<>@,;:\\\\"\.\[\]]+|"[^"\\\\\n\r]+")(?:\.[ \t]*(?:[^\x00-\x20\(\)<>@,;:\\\\"\.\[\]]+|"[^"\\\\\n\r]+"[ \t]*))*)@((?:[a-z0-9\\-]+\.)+[a-z]{2,}|\[(?:(?:[01]?\d?\d|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d?\d|2[0-4]\d|25[0-5])\])';
|
509 |
-
$name_regex = '((?:[^\x00-\x20\(\)<>@,;:\\\\"\.\[\]]+[ \t]*|"[^"
|
510 |
|
511 |
if (preg_match('~^[ \t]*' . $name_regex . '[ \t]*<[ \t]*' . $email_regex . '[ \t]*>[ \t]*$~ixD', $string, $match)) {
|
512 |
$match[1] = trim($match[1]);
|
@@ -557,7 +557,6 @@ class fMailbox {
|
|
557 |
* Parses full email headers into an associative array
|
558 |
*
|
559 |
* @param string $headers The header to parse
|
560 |
-
* @param string $filter Remove any headers that match this
|
561 |
* @return array The parsed headers
|
562 |
*/
|
563 |
static public function parseHeaders($headers) {
|
506 |
*/
|
507 |
static private function parseEmail($string) {
|
508 |
$email_regex = '((?:[^\x00-\x20\(\)<>@,;:\\\\"\.\[\]]+|"[^"\\\\\n\r]+")(?:\.[ \t]*(?:[^\x00-\x20\(\)<>@,;:\\\\"\.\[\]]+|"[^"\\\\\n\r]+"[ \t]*))*)@((?:[a-z0-9\\-]+\.)+[a-z]{2,}|\[(?:(?:[01]?\d?\d|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d?\d|2[0-4]\d|25[0-5])\])';
|
509 |
+
$name_regex = '((?:[^\x00-\x20\(\)<>@,;:\\\\"\.\[\]]+[ \t]*|"[^"\n\r]+"[ \t]*)(?:\.?[ \t]*(?:[^\x00-\x20\(\)<>@,;:\\\\"\.\[\]]+[ \t]*|"[^"\\\\\n\r]+"[ \t]*))*)';
|
510 |
|
511 |
if (preg_match('~^[ \t]*' . $name_regex . '[ \t]*<[ \t]*' . $email_regex . '[ \t]*>[ \t]*$~ixD', $string, $match)) {
|
512 |
$match[1] = trim($match[1]);
|
557 |
* Parses full email headers into an associative array
|
558 |
*
|
559 |
* @param string $headers The header to parse
|
|
|
560 |
* @return array The parsed headers
|
561 |
*/
|
562 |
static public function parseHeaders($headers) {
|
postie-filters.php
CHANGED
@@ -214,19 +214,20 @@ function filter_RemoveSignature($content, $config) {
|
|
214 |
DebugEcho("filter_RemoveSignature: no sig_pattern_list");
|
215 |
return $content;
|
216 |
}
|
217 |
-
|
218 |
-
|
219 |
-
$pattern = '/^(' . implode('|', $config['sig_pattern_list']) . ')\s?$/miu';
|
220 |
-
DebugEcho("filter_RemoveSignature: pattern: $pattern");
|
221 |
|
222 |
$html = $g_postie->load_html($content);
|
223 |
if ($html !== false && $config['prefer_text_type'] == 'html') {
|
224 |
DebugEcho("filter_RemoveSignature: html");
|
|
|
|
|
225 |
filter_RemoveSignatureWorker($html->root, $pattern);
|
226 |
//DebugEcho("filter_RemoveSignature: post worker: $html");
|
227 |
$content = $html->save();
|
228 |
} else {
|
229 |
DebugEcho("filter_RemoveSignature: plain");
|
|
|
|
|
230 |
$arrcontent = explode("\n", $content);
|
231 |
$strcontent = '';
|
232 |
|
@@ -251,9 +252,11 @@ function filter_RemoveSignature($content, $config) {
|
|
251 |
function filter_RemoveSignatureWorker(&$html, $pattern) {
|
252 |
$found = false;
|
253 |
$matches = array();
|
254 |
-
|
|
|
|
|
255 |
$sig = trim($matches[1]);
|
256 |
-
DebugEcho("filter_RemoveSignatureWorker: signature '$sig' found in:\n" .
|
257 |
//DebugDump($matches);
|
258 |
$found = true;
|
259 |
$i = stripos($html->innertext, $sig);
|
@@ -266,7 +269,10 @@ function filter_RemoveSignatureWorker(&$html, $pattern) {
|
|
266 |
//DebugEcho("filter_RemoveSignatureWorker: signature not found: '$sig' " . strlen($sig));
|
267 |
}
|
268 |
} else {
|
269 |
-
|
|
|
|
|
|
|
270 |
//DebugDump($matches);
|
271 |
}
|
272 |
|
@@ -459,8 +465,8 @@ function filter_ReplaceImagePlaceHolders($content, &$email, $config, $post_id, $
|
|
459 |
'post_type' => 'attachment',
|
460 |
'numberposts' => -1,
|
461 |
'post_mime_type' => 'image',));
|
462 |
-
DebugEcho("filter_ReplaceImagePlaceHolders: images in post: " . count($images));
|
463 |
-
DebugDump($images);
|
464 |
|
465 |
$i = 0;
|
466 |
|
214 |
DebugEcho("filter_RemoveSignature: no sig_pattern_list");
|
215 |
return $content;
|
216 |
}
|
217 |
+
DebugEcho("looking for signature in: $content");
|
|
|
|
|
|
|
218 |
|
219 |
$html = $g_postie->load_html($content);
|
220 |
if ($html !== false && $config['prefer_text_type'] == 'html') {
|
221 |
DebugEcho("filter_RemoveSignature: html");
|
222 |
+
$pattern = '/>\s*(' . implode('|', $config['sig_pattern_list']) . ')/miu';
|
223 |
+
DebugEcho("filter_RemoveSignature: pattern: $pattern");
|
224 |
filter_RemoveSignatureWorker($html->root, $pattern);
|
225 |
//DebugEcho("filter_RemoveSignature: post worker: $html");
|
226 |
$content = $html->save();
|
227 |
} else {
|
228 |
DebugEcho("filter_RemoveSignature: plain");
|
229 |
+
$pattern = '/^(' . implode('|', $config['sig_pattern_list']) . ')\s?$/miu';
|
230 |
+
DebugEcho("filter_RemoveSignature: pattern: $pattern");
|
231 |
$arrcontent = explode("\n", $content);
|
232 |
$strcontent = '';
|
233 |
|
252 |
function filter_RemoveSignatureWorker(&$html, $pattern) {
|
253 |
$found = false;
|
254 |
$matches = array();
|
255 |
+
$subject = trim($html);
|
256 |
+
$pm = preg_match($pattern, $subject, $matches);
|
257 |
+
if ($pm === 1) {
|
258 |
$sig = trim($matches[1]);
|
259 |
+
DebugEcho("filter_RemoveSignatureWorker: signature '$sig' found in:\n" . $subject);
|
260 |
//DebugDump($matches);
|
261 |
$found = true;
|
262 |
$i = stripos($html->innertext, $sig);
|
269 |
//DebugEcho("filter_RemoveSignatureWorker: signature not found: '$sig' " . strlen($sig));
|
270 |
}
|
271 |
} else {
|
272 |
+
if ($pm === false) {
|
273 |
+
DebugEcho('filter_RemoveSignatureWorker: preg_match error ' . preg_last_error());
|
274 |
+
}
|
275 |
+
DebugEcho("filter_RemoveSignatureWorker: no matches " . preg_last_error() . " '$pattern' $subject");
|
276 |
//DebugDump($matches);
|
277 |
}
|
278 |
|
465 |
'post_type' => 'attachment',
|
466 |
'numberposts' => -1,
|
467 |
'post_mime_type' => 'image',));
|
468 |
+
//DebugEcho("filter_ReplaceImagePlaceHolders: images in post: " . count($images));
|
469 |
+
//DebugDump($images);
|
470 |
|
471 |
$i = 0;
|
472 |
|
postie-tags.php
CHANGED
@@ -456,7 +456,7 @@ function tag_Tags(&$content, $config) {
|
|
456 |
foreach (postie_content_lines($content, $config) as $line) {
|
457 |
//DebugEcho("tag_Tags: line: $line");
|
458 |
$matches = array();
|
459 |
-
|
460 |
if (!empty($matches[1])) {
|
461 |
DebugEcho("tag_Tags: Found tags: $matches[1]");
|
462 |
$content = str_replace($matches[0], "", $content);
|
456 |
foreach (postie_content_lines($content, $config) as $line) {
|
457 |
//DebugEcho("tag_Tags: line: $line");
|
458 |
$matches = array();
|
459 |
+
if (preg_match('/^\s*tags:\s*(.*)/imu', $line, $matches)) {
|
460 |
if (!empty($matches[1])) {
|
461 |
DebugEcho("tag_Tags: Found tags: $matches[1]");
|
462 |
$content = str_replace($matches[0], "", $content);
|
postie.class.php
CHANGED
@@ -52,12 +52,12 @@ class Postie {
|
|
52 |
}
|
53 |
add_filter('intermediate_image_sizes_advanced', array($this, 'intermediate_image_sizes_advanced'));
|
54 |
|
55 |
-
DebugEcho('Starting mail fetch');
|
56 |
-
DebugEcho('WordPress datetime: ' . current_time('mysql'));
|
57 |
-
|
58 |
DebugEcho("doing postie_session_start");
|
59 |
do_action('postie_session_start');
|
60 |
|
|
|
|
|
|
|
61 |
$wp_content_path = dirname(dirname(dirname(__FILE__)));
|
62 |
DebugEcho("wp_content_path: $wp_content_path");
|
63 |
if (file_exists($wp_content_path . DIRECTORY_SEPARATOR . 'filterPostie.php')) {
|
@@ -80,59 +80,16 @@ class Postie {
|
|
80 |
$config['maxemails'] = 0;
|
81 |
}
|
82 |
|
83 |
-
$conninfo = $this->connection_info($config);
|
84 |
-
|
85 |
-
$emails = $this->fetch_mail($conninfo['mail_server'], $conninfo['mail_port'], $conninfo['mail_user'], $conninfo['mail_password'], $conninfo['mail_protocol'], $conninfo['email_delete_after_processing'], $conninfo['email_max'], $config['input_connection']);
|
86 |
-
|
87 |
-
$message = 'Done.';
|
88 |
-
|
89 |
-
DebugEcho(sprintf(__("There are %d messages to process", 'postie'), count($emails)));
|
90 |
-
|
91 |
//don't output the password
|
|
|
92 |
$tmp_config = $config;
|
93 |
unset($tmp_config['mail_password']);
|
94 |
DebugDump($tmp_config);
|
95 |
|
96 |
-
|
97 |
-
$message_number = 0;
|
98 |
-
foreach ($emails as $email) {
|
99 |
-
$message_number++;
|
100 |
-
DebugEcho("$message_number: ------------------------------------");
|
101 |
-
//DebugDump($email);
|
102 |
-
//sanity check to see if there is any info in the message
|
103 |
-
if ($email == NULL) {
|
104 |
-
$message = __('Dang, message is empty!', 'postie');
|
105 |
-
EchoError("$message_number: $message");
|
106 |
-
continue;
|
107 |
-
} else if ($email == 'already read') {
|
108 |
-
$message = __("Message is already marked 'read'.", 'postie');
|
109 |
-
DebugEcho("$message_number: $message");
|
110 |
-
continue;
|
111 |
-
}
|
112 |
|
113 |
-
|
114 |
-
if ($config['prefer_text_convert']) {
|
115 |
-
if ($config['prefer_text_type'] == 'plain' && trim($email['text']) == '' && trim($email['html']) != '') {
|
116 |
-
DebugEcho('get_mail: switching to html');
|
117 |
-
$tmp_config['prefer_text_type'] = 'html';
|
118 |
-
}
|
119 |
-
if ($config['prefer_text_type'] == 'html' && trim($email['html']) == '' && trim($email['text']) != '') {
|
120 |
-
DebugEcho('get_mail: switching to plain');
|
121 |
-
$tmp_config['prefer_text_type'] = 'plain';
|
122 |
-
}
|
123 |
-
}
|
124 |
|
125 |
-
//Check poster to see if a valid person
|
126 |
-
$poster = $this->validate_poster($email, $tmp_config);
|
127 |
-
if (!empty($poster)) {
|
128 |
-
$this->post_email($poster, $email, $tmp_config);
|
129 |
-
DebugEcho("$message_number: processed");
|
130 |
-
} else {
|
131 |
-
EchoError('Ignoring email - not authorized.');
|
132 |
-
}
|
133 |
-
flush();
|
134 |
-
}
|
135 |
-
DebugEcho("Mail fetch complete, $message_number emails");
|
136 |
DebugEcho("doing postie_session_end");
|
137 |
do_action('postie_session_end');
|
138 |
|
@@ -1113,11 +1070,11 @@ class Postie {
|
|
1113 |
}
|
1114 |
}
|
1115 |
|
1116 |
-
function get_emails($type, $server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $
|
1117 |
|
1118 |
DebugEcho("getemails: Connecting to $server:$port ($protocol)");
|
1119 |
|
1120 |
-
$
|
1121 |
|
1122 |
try {
|
1123 |
DebugEcho("getemails: procol: $protocol");
|
@@ -1137,9 +1094,14 @@ class Postie {
|
|
1137 |
$mailbox = new fMailbox($type, $conn, $srv);
|
1138 |
$messages = $mailbox->listMessages($maxemails);
|
1139 |
|
|
|
|
|
1140 |
DebugDump($messages);
|
1141 |
|
|
|
1142 |
foreach ($messages as $message) {
|
|
|
|
|
1143 |
DebugEcho("getemails: fetch {$message['uid']}");
|
1144 |
|
1145 |
$email = $mailbox->fetchMessage($message['uid']);
|
@@ -1151,7 +1113,41 @@ class Postie {
|
|
1151 |
DebugEcho("getemails: no html");
|
1152 |
}
|
1153 |
|
1154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1155 |
if ($deleteMessages) {
|
1156 |
DebugEcho("getemails: deleting {$message['uid']}");
|
1157 |
$mailbox->deleteMessages($message['uid']);
|
@@ -1160,18 +1156,18 @@ class Postie {
|
|
1160 |
|
1161 |
DebugEcho("getemails: closing connection");
|
1162 |
$mailbox->close();
|
|
|
|
|
1163 |
} catch (Exception $e) {
|
1164 |
EchoError("getemails: " . $e->getMessage());
|
1165 |
}
|
1166 |
-
|
1167 |
-
return $emails;
|
1168 |
}
|
1169 |
|
1170 |
/**
|
1171 |
* This function handles determining the protocol and fetching the mail
|
1172 |
* @return array
|
1173 |
*/
|
1174 |
-
function fetch_mail($server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $
|
1175 |
$emails = array();
|
1176 |
if (!$server || !$port || !$email) {
|
1177 |
EchoError("Missing Configuration For Mail Server");
|
@@ -1183,12 +1179,12 @@ class Postie {
|
|
1183 |
switch (strtolower($protocol)) {
|
1184 |
case 'imap':
|
1185 |
case 'imap-ssl':
|
1186 |
-
$emails = $this->get_emails('imap', $server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $
|
1187 |
break;
|
1188 |
case 'pop3':
|
1189 |
case 'pop3-ssl':
|
1190 |
default:
|
1191 |
-
$emails = $this->get_emails('pop3', $server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $
|
1192 |
}
|
1193 |
|
1194 |
return $emails;
|
@@ -1447,7 +1443,7 @@ class Postie {
|
|
1447 |
function validate_poster(&$mimeDecodedEmail, $config) {
|
1448 |
extract($config);
|
1449 |
$poster = NULL;
|
1450 |
-
$from =
|
1451 |
if (array_key_exists('headers', $mimeDecodedEmail) && array_key_exists('from', $mimeDecodedEmail['headers'])) {
|
1452 |
$from = $mimeDecodedEmail['headers']['from']['mailbox'] . '@' . $mimeDecodedEmail['headers']['from']['host'];
|
1453 |
$from = apply_filters('postie_filter_email', $from);
|
@@ -1475,7 +1471,7 @@ class Postie {
|
|
1475 |
DebugEcho("validate_poster: post postie_filter_email3 $from");
|
1476 |
}
|
1477 |
|
1478 |
-
$resentFrom =
|
1479 |
if (array_key_exists('headers', $mimeDecodedEmail) && array_key_exists('resent-from', $mimeDecodedEmail['headers'])) {
|
1480 |
$resentFrom = $this->remove_extra_characters_in_email_address(trim($mimeDecodedEmail['headers']['resent-from']));
|
1481 |
}
|
@@ -1703,7 +1699,12 @@ class Postie {
|
|
1703 |
}
|
1704 |
|
1705 |
DebugEcho('Active plugins', $force_display);
|
1706 |
-
|
|
|
|
|
|
|
|
|
|
|
1707 |
|
1708 |
DebugEcho("Postie is in " . plugin_dir_path(__FILE__), $force_display);
|
1709 |
DebugEcho("Postie Version: " . POSTIE_VERSION, $force_display);
|
52 |
}
|
53 |
add_filter('intermediate_image_sizes_advanced', array($this, 'intermediate_image_sizes_advanced'));
|
54 |
|
|
|
|
|
|
|
55 |
DebugEcho("doing postie_session_start");
|
56 |
do_action('postie_session_start');
|
57 |
|
58 |
+
DebugEcho('Starting mail fetch');
|
59 |
+
DebugEcho('WordPress datetime: ' . current_time('mysql'));
|
60 |
+
|
61 |
$wp_content_path = dirname(dirname(dirname(__FILE__)));
|
62 |
DebugEcho("wp_content_path: $wp_content_path");
|
63 |
if (file_exists($wp_content_path . DIRECTORY_SEPARATOR . 'filterPostie.php')) {
|
80 |
$config['maxemails'] = 0;
|
81 |
}
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
//don't output the password
|
84 |
+
DebugEcho("postie configuration");
|
85 |
$tmp_config = $config;
|
86 |
unset($tmp_config['mail_password']);
|
87 |
DebugDump($tmp_config);
|
88 |
|
89 |
+
$conninfo = $this->connection_info($config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
+
$this->fetch_mail($conninfo['mail_server'], $conninfo['mail_port'], $conninfo['mail_user'], $conninfo['mail_password'], $conninfo['mail_protocol'], $conninfo['email_delete_after_processing'], $conninfo['email_max'], $config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
DebugEcho("doing postie_session_end");
|
94 |
do_action('postie_session_end');
|
95 |
|
1070 |
}
|
1071 |
}
|
1072 |
|
1073 |
+
function get_emails($type, $server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $config) {
|
1074 |
|
1075 |
DebugEcho("getemails: Connecting to $server:$port ($protocol)");
|
1076 |
|
1077 |
+
$connectiontype = $config['input_connection'];
|
1078 |
|
1079 |
try {
|
1080 |
DebugEcho("getemails: procol: $protocol");
|
1094 |
$mailbox = new fMailbox($type, $conn, $srv);
|
1095 |
$messages = $mailbox->listMessages($maxemails);
|
1096 |
|
1097 |
+
DebugEcho(sprintf(__("There are %d messages to process", 'postie'), count($messages)));
|
1098 |
+
|
1099 |
DebugDump($messages);
|
1100 |
|
1101 |
+
$message_number = 0;
|
1102 |
foreach ($messages as $message) {
|
1103 |
+
$message_number++;
|
1104 |
+
DebugEcho("$message_number: ------------------------------------");
|
1105 |
DebugEcho("getemails: fetch {$message['uid']}");
|
1106 |
|
1107 |
$email = $mailbox->fetchMessage($message['uid']);
|
1113 |
DebugEcho("getemails: no html");
|
1114 |
}
|
1115 |
|
1116 |
+
|
1117 |
+
//DebugDump($email);
|
1118 |
+
//sanity check to see if there is any info in the message
|
1119 |
+
if ($email == NULL) {
|
1120 |
+
$message = __('Dang, message is empty!', 'postie');
|
1121 |
+
EchoError("$message_number: $message");
|
1122 |
+
continue;
|
1123 |
+
} else if ($email == 'already read') {
|
1124 |
+
$message = __("Message is already marked 'read'.", 'postie');
|
1125 |
+
DebugEcho("$message_number: $message");
|
1126 |
+
continue;
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
$tmp_config = $config;
|
1130 |
+
if ($config['prefer_text_convert']) {
|
1131 |
+
if ($config['prefer_text_type'] == 'plain' && trim($email['text']) == '' && trim($email['html']) != '') {
|
1132 |
+
DebugEcho('get_mail: switching to html');
|
1133 |
+
$tmp_config['prefer_text_type'] = 'html';
|
1134 |
+
}
|
1135 |
+
if ($config['prefer_text_type'] == 'html' && trim($email['html']) == '' && trim($email['text']) != '') {
|
1136 |
+
DebugEcho('get_mail: switching to plain');
|
1137 |
+
$tmp_config['prefer_text_type'] = 'plain';
|
1138 |
+
}
|
1139 |
+
}
|
1140 |
+
|
1141 |
+
//Check poster to see if a valid person
|
1142 |
+
$poster = $this->validate_poster($email, $tmp_config);
|
1143 |
+
if (!empty($poster)) {
|
1144 |
+
$this->post_email($poster, $email, $tmp_config);
|
1145 |
+
DebugEcho("$message_number: processed");
|
1146 |
+
} else {
|
1147 |
+
EchoError('Ignoring email - not authorized.');
|
1148 |
+
}
|
1149 |
+
flush();
|
1150 |
+
|
1151 |
if ($deleteMessages) {
|
1152 |
DebugEcho("getemails: deleting {$message['uid']}");
|
1153 |
$mailbox->deleteMessages($message['uid']);
|
1156 |
|
1157 |
DebugEcho("getemails: closing connection");
|
1158 |
$mailbox->close();
|
1159 |
+
|
1160 |
+
DebugEcho("Mail fetch complete, $message_number emails");
|
1161 |
} catch (Exception $e) {
|
1162 |
EchoError("getemails: " . $e->getMessage());
|
1163 |
}
|
|
|
|
|
1164 |
}
|
1165 |
|
1166 |
/**
|
1167 |
* This function handles determining the protocol and fetching the mail
|
1168 |
* @return array
|
1169 |
*/
|
1170 |
+
function fetch_mail($server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $config) {
|
1171 |
$emails = array();
|
1172 |
if (!$server || !$port || !$email) {
|
1173 |
EchoError("Missing Configuration For Mail Server");
|
1179 |
switch (strtolower($protocol)) {
|
1180 |
case 'imap':
|
1181 |
case 'imap-ssl':
|
1182 |
+
$emails = $this->get_emails('imap', $server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $config);
|
1183 |
break;
|
1184 |
case 'pop3':
|
1185 |
case 'pop3-ssl':
|
1186 |
default:
|
1187 |
+
$emails = $this->get_emails('pop3', $server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $config);
|
1188 |
}
|
1189 |
|
1190 |
return $emails;
|
1443 |
function validate_poster(&$mimeDecodedEmail, $config) {
|
1444 |
extract($config);
|
1445 |
$poster = NULL;
|
1446 |
+
$from = '';
|
1447 |
if (array_key_exists('headers', $mimeDecodedEmail) && array_key_exists('from', $mimeDecodedEmail['headers'])) {
|
1448 |
$from = $mimeDecodedEmail['headers']['from']['mailbox'] . '@' . $mimeDecodedEmail['headers']['from']['host'];
|
1449 |
$from = apply_filters('postie_filter_email', $from);
|
1471 |
DebugEcho("validate_poster: post postie_filter_email3 $from");
|
1472 |
}
|
1473 |
|
1474 |
+
$resentFrom = '';
|
1475 |
if (array_key_exists('headers', $mimeDecodedEmail) && array_key_exists('resent-from', $mimeDecodedEmail['headers'])) {
|
1476 |
$resentFrom = $this->remove_extra_characters_in_email_address(trim($mimeDecodedEmail['headers']['resent-from']));
|
1477 |
}
|
1699 |
}
|
1700 |
|
1701 |
DebugEcho('Active plugins', $force_display);
|
1702 |
+
$plugins = get_option('active_plugins');
|
1703 |
+
foreach ($plugins as $plugin) {
|
1704 |
+
$plugin_data = get_file_data(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin, array('Version' => 'Version'), false);
|
1705 |
+
$plugin_version = $plugin_data['Version'];
|
1706 |
+
DebugEcho(" $plugin => $plugin_version", $force_display);
|
1707 |
+
}
|
1708 |
|
1709 |
DebugEcho("Postie is in " . plugin_dir_path(__FILE__), $force_display);
|
1710 |
DebugEcho("Postie Version: " . POSTIE_VERSION, $force_display);
|
postie.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Postie
|
5 |
Plugin URI: http://PostiePlugin.com/
|
6 |
Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
|
7 |
-
Version: 1.9.
|
8 |
Author: Wayne Allen
|
9 |
Author URI: http://PostiePlugin.com/
|
10 |
License: GPL3
|
@@ -28,14 +28,17 @@
|
|
28 |
*/
|
29 |
|
30 |
/*
|
31 |
-
$Id: postie.php
|
32 |
*/
|
33 |
|
34 |
if (!defined('WPINC')) {
|
35 |
die; // Exit if accessed directly
|
36 |
}
|
37 |
|
38 |
-
|
|
|
|
|
|
|
39 |
define('POSTIE_ROOT', dirname(__FILE__));
|
40 |
define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
|
41 |
|
4 |
Plugin Name: Postie
|
5 |
Plugin URI: http://PostiePlugin.com/
|
6 |
Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
|
7 |
+
Version: 1.9.42
|
8 |
Author: Wayne Allen
|
9 |
Author URI: http://PostiePlugin.com/
|
10 |
License: GPL3
|
28 |
*/
|
29 |
|
30 |
/*
|
31 |
+
$Id: postie.php 2246483 2020-02-18 22:54:51Z WayneAllen $
|
32 |
*/
|
33 |
|
34 |
if (!defined('WPINC')) {
|
35 |
die; // Exit if accessed directly
|
36 |
}
|
37 |
|
38 |
+
$plugin_data = get_file_data(__FILE__, array('Version' => 'Version'), false);
|
39 |
+
$plugin_version = $plugin_data['Version'];
|
40 |
+
|
41 |
+
define('POSTIE_VERSION', $plugin_version);
|
42 |
define('POSTIE_ROOT', dirname(__FILE__));
|
43 |
define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
|
44 |
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: e-mail, email, post-by-email
|
|
7 |
Requires PHP: 5.3
|
8 |
Requires at least: 4.0
|
9 |
Tested up to: 5.3
|
10 |
-
Stable tag: 1.9.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -107,6 +107,13 @@ All script, style and body tags are stripped from html emails.
|
|
107 |
Attachments are now processed in the order they were attached.
|
108 |
|
109 |
== CHANGELOG ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
= 1.9.40 (2019-11-13) =
|
111 |
* Fix issue with class-oembed.php upgrade
|
112 |
|
@@ -1555,3 +1562,4 @@ plugin. And the rest is history :)
|
|
1555 |
*
|
1556 |
= 0.1 - 2004-06 =
|
1557 |
* First release
|
|
7 |
Requires PHP: 5.3
|
8 |
Requires at least: 4.0
|
9 |
Tested up to: 5.3
|
10 |
+
Stable tag: 1.9.42
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
107 |
Attachments are now processed in the order they were attached.
|
108 |
|
109 |
== CHANGELOG ==
|
110 |
+
= 1.9.42 (2020-02-18) =
|
111 |
+
* Fix: signature stripping in html emails was failing sometimes
|
112 |
+
|
113 |
+
= 1.9.41 (2020-02-01) =
|
114 |
+
* Fix: different regex approach for html vs plain
|
115 |
+
* Only process 1 email at a time
|
116 |
+
|
117 |
= 1.9.40 (2019-11-13) =
|
118 |
* Fix issue with class-oembed.php upgrade
|
119 |
|
1562 |
*
|
1563 |
= 0.1 - 2004-06 =
|
1564 |
* First release
|
1565 |
+
|