Postie - Version 1.7.20

Version Description

(2015-10-26) = * Fixed bug where debug info was not being displayed according to settings * Fix bug where "Ignore mail state" setting was being ignored * Fix bug where empty post was being generated when already read mail was in the inbox and "Ignore mail state" was "Yes" * Added postie_session_start and postie_session_end actions

Download this release

Release Info

Developer WayneAllen
Plugin Icon 128x128 Postie
Version 1.7.20
Comparing to
See all releases

Code changes from version 1.7.18 to 1.7.20

Files changed (8) hide show
  1. config_form.php +4 -4
  2. docs/Changes.txt +9 -0
  3. docs/Postie.txt +1 -1
  4. docs/TODO.txt +0 -2
  5. postie-functions.php +105 -95
  6. postie.php +3 -3
  7. postieIMAP.php +4 -4
  8. readme.txt +10 -1
config_form.php CHANGED
@@ -37,12 +37,12 @@
37
  exit;
38
  break;
39
  case "runpostie":
40
- EchoInfo(__("Checking for mail manually", 'postie'));
41
  postie_get_mail();
42
  exit;
43
  break;
44
  case "runpostie-debug":
45
- EchoInfo(__("Checking for mail manually with debug output", 'postie'));
46
  if (!defined('POSTIE_DEBUG')) {
47
  define('POSTIE_DEBUG', true);
48
  }
@@ -71,7 +71,7 @@
71
  }
72
  extract($config);
73
  if (!isset($maxemails)) {
74
- EchoInfo(__("New setting: maxemails", 'postie'));
75
  $maxemails = 0;
76
  }
77
  if (!isset($category_match)) {
@@ -515,7 +515,7 @@
515
 
516
  <?php
517
  echo BuildBooleanSelect(__("Use First Image as Featured Image", 'postie'), "postie-settings[featured_image]", $featured_image, __("If any images are attached, the first one will be the featured image for the post", 'postie'));
518
- echo BuildBooleanSelect(__("Include Featured Image in Post", 'postie'), "postie-settings[include_featured_image]", $include_featured_image, __("Should the featured image be included in the post", 'postie'));
519
  echo BuildBooleanSelect(__("Automatically insert image gallery", 'postie'), "postie-settings[auto_gallery]", $auto_gallery, __("If any images are attached, they will automatically be inserted as a gallery", 'postie'));
520
  echo BuildSelect(__("Gallery Link Type", 'postie'), "postie-settings[auto_gallery_link]", $auto_gallery_link, array('Default', 'Post', 'File', 'None'), "Select the type of link the gallery should use");
521
  echo BuildBooleanSelect(__("Image Location", 'postie'), "postie-settings[images_append]", $images_append, __("Location of attachments if using 'plain' format. Before or After content.", 'postie'), array('After', 'Before'));
37
  exit;
38
  break;
39
  case "runpostie":
40
+ DebugEcho(__("Checking for mail manually", 'postie'));
41
  postie_get_mail();
42
  exit;
43
  break;
44
  case "runpostie-debug":
45
+ DebugEcho(__("Checking for mail manually with debug output", 'postie'));
46
  if (!defined('POSTIE_DEBUG')) {
47
  define('POSTIE_DEBUG', true);
48
  }
71
  }
72
  extract($config);
73
  if (!isset($maxemails)) {
74
+ DebugEcho(__("New setting: maxemails", 'postie'));
75
  $maxemails = 0;
76
  }
77
  if (!isset($category_match)) {
515
 
516
  <?php
517
  echo BuildBooleanSelect(__("Use First Image as Featured Image", 'postie'), "postie-settings[featured_image]", $featured_image, __("If any images are attached, the first one will be the featured image for the post", 'postie'));
518
+ echo BuildBooleanSelect(__("Include Featured Image in Post", 'postie'), "postie-settings[include_featured_image]", $include_featured_image, __("Should the featured image be included in the post. This only works if the 'Preferred Text Type' is 'Plain'", 'postie'));
519
  echo BuildBooleanSelect(__("Automatically insert image gallery", 'postie'), "postie-settings[auto_gallery]", $auto_gallery, __("If any images are attached, they will automatically be inserted as a gallery", 'postie'));
520
  echo BuildSelect(__("Gallery Link Type", 'postie'), "postie-settings[auto_gallery_link]", $auto_gallery_link, array('Default', 'Post', 'File', 'None'), "Select the type of link the gallery should use");
521
  echo BuildBooleanSelect(__("Image Location", 'postie'), "postie-settings[images_append]", $images_append, __("Location of attachments if using 'plain' format. Before or After content.", 'postie'), array('After', 'Before'));
docs/Changes.txt CHANGED
@@ -27,6 +27,15 @@ All script, style and body tags are stripped from html emails.
27
  Attachments are now processed in the order they were attached.
28
 
29
  == CHANGELOG ==
 
 
 
 
 
 
 
 
 
30
  = 1.7.18 (2015-10-13) =
31
  * Fix bug where linkify was messing up CID reference
32
 
27
  Attachments are now processed in the order they were attached.
28
 
29
  == CHANGELOG ==
30
+ = 1.7.20 (2015-10-26) =
31
+ * Fixed bug where debug info was not being displayed according to settings
32
+ * Fix bug where "Ignore mail state" setting was being ignored
33
+ * Fix bug where empty post was being generated when already read mail was in the inbox and "Ignore mail state" was "Yes"
34
+ * Added postie_session_start and postie_session_end actions
35
+
36
+ = 1.7.19 (2015-10-13) =
37
+ * Fixed bug where allowed mime types was not being respected.
38
+
39
  = 1.7.18 (2015-10-13) =
40
  * Fix bug where linkify was messing up CID reference
41
 
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.3.1
9
- Stable tag: 1.7.18
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.3.1
9
+ Stable tag: 1.7.20
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
docs/TODO.txt CHANGED
@@ -54,8 +54,6 @@ hook for actions
54
  non-permitted attachment types
55
  email rejected
56
  email connection failure
57
- start check
58
- end check
59
  mail read
60
  mail delete
61
  content part
54
  non-permitted attachment types
55
  email rejected
56
  email connection failure
 
 
57
  mail read
58
  mail delete
59
  content part
postie-functions.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- $Id: postie-functions.php 1265241 2015-10-13 20:16:04Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
@@ -57,30 +57,30 @@ if (!function_exists('mb_str_replace')) {
57
  }
58
  }
59
 
60
- function postie_environment() {
61
- EchoInfo("Postie Version: " . POSTIE_VERSION);
62
- EchoInfo("Wordpress Version: " . get_bloginfo('version'));
63
- EchoInfo("PHP Version: " . phpversion());
64
- EchoInfo("OS: " . php_uname());
65
- EchoInfo("POSTIE_DEBUG: " . (IsDebugMode() ? "On" : "Off"));
66
- EchoInfo("Time: " . date('Y-m-d H:i:s', time()) . " GMT");
67
- DebugEcho("Error log: " . ini_get('error_log'));
68
- DebugEcho("TMP dir: " . get_temp_dir());
69
- DebugEcho("Postie is in " . plugin_dir_path(__FILE__));
70
 
71
  if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
72
- EchoInfo("Alternate cron is enabled");
73
  }
74
 
75
  if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
76
- EchoInfo("WordPress cron is disabled. Postie will not run unless you have an external cron set up.");
77
  }
78
 
79
- EchoInfo("Cron: " . (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON === true ? "Off" : "On"));
80
- EchoInfo("Alternate Cron: " . (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON === true ? "On" : "Off"));
81
 
82
  if (defined('WP_CRON_LOCK_TIMEOUT') && WP_CRON_LOCK_TIMEOUT === true) {
83
- EchoInfo("Cron lock timeout is:" . WP_CRON_LOCK_TIMEOUT);
84
  }
85
  }
86
 
@@ -131,8 +131,8 @@ function postie_log_debug($data) {
131
  error_log("Postie [debug]: $data");
132
  }
133
 
134
- function EchoInfo($v) {
135
- postie_log_onscreen($v);
136
  do_action('postie_log_debug', $v);
137
  }
138
 
@@ -143,8 +143,8 @@ function DebugDump($v) {
143
  do_action('postie_log_debug', print_r($v, true));
144
  }
145
 
146
- function DebugEcho($v) {
147
- if (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG) {
148
  postie_log_onscreen($v);
149
  }
150
  do_action('postie_log_debug', $v);
@@ -455,7 +455,7 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
455
  // then it should be removed
456
  if (!$is_reply) {
457
  wp_delete_post($post_id);
458
- EchoInfo("postie_post filter cleared the post, not saving.");
459
  }
460
  } else {
461
  DisplayEmailPost($details);
@@ -470,11 +470,13 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
470
  } elseif ($confirmation_email == 'both') {
471
  $recipients = array($details['email_author'], get_option("admin_email"));
472
  }
473
- MailToRecipients($mimeDecodedEmail, false, $recipients, false, false, $postid);
 
 
474
  }
475
  }
476
  } else {
477
- EchoInfo("wp_insert_post failed: " . $post_id->get_error_message());
478
  DebugDump($post_id->get_error_messages());
479
  DebugDump($post_id->get_error_data());
480
  }
@@ -757,11 +759,11 @@ function ConfigurePostie() {
757
  function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0, $email_tls = false) {
758
  $emails = array();
759
  if (!$server || !$port || !$email) {
760
- EchoInfo("Missing Configuration For Mail Server");
761
  return $emails;
762
  }
763
  if ($server == "pop.gmail.com") {
764
- EchoInfo("MAKE SURE POP IS TURNED ON IN SETTING AT Gmail");
765
  }
766
  switch (strtolower($protocol)) {
767
  case 'smtp': //direct
@@ -777,7 +779,7 @@ function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL
777
  case 'imap-ssl':
778
  case 'pop3-ssl':
779
  if (!HasIMAPSupport()) {
780
- EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting.");
781
  } else {
782
  $emails = IMAPMessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages, $maxemails, $email_tls);
783
  }
@@ -793,7 +795,7 @@ function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL
793
  /**
794
  * Handles fetching messages from an imap server
795
  */
796
- function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0, $tls = false) {
797
  require_once("postieIMAP.php");
798
  $emails = array();
799
  $mail_server = &PostieIMAP::Factory($protocol);
@@ -804,15 +806,15 @@ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password
804
  if ($mail_server->connect(trim($server), $port, $email, $password)) {
805
  $msg_count = $mail_server->getNumberOfMessages();
806
  } else {
807
- EchoInfo("Mail Connection Time Out");
808
- EchoInfo("Common Reasons: Server Down, Network Issue, Port/Protocol MisMatch ");
809
- EchoInfo("The Server said:" . $mail_server->error());
810
  $msg_count = 0;
811
  }
812
 
813
  // loop through messages
814
  for ($i = 1; $i <= $msg_count; $i++) {
815
- $emails[$i] = $mail_server->fetchEmail($i);
816
  if ($deleteMessages) {
817
  $mail_server->deleteMessage($i);
818
  }
@@ -850,9 +852,9 @@ function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password
850
  }
851
  } else {
852
  if (strpos($pop3->ERROR, "POP3: premature NOOP OK, NOT an RFC 1939 Compliant server") === false) {
853
- EchoInfo("Mail Connection Time Out. Common Reasons: Server Down, Network Issue, Port/Protocol MisMatch");
854
  }
855
- EchoInfo("The Server said: $pop3->ERROR");
856
  $msg_count = 0;
857
  }
858
  DebugEcho("message count: $msg_count");
@@ -869,7 +871,7 @@ function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password
869
  $emails[$i] = implode('', $m);
870
  if ($deleteMessages) {
871
  if (!$pop3->delete($i)) {
872
- EchoInfo("POP3MessageFetch: cannot delete message $i: " . $pop3->ERROR);
873
  $pop3->reset();
874
  exit;
875
  }
@@ -878,7 +880,7 @@ function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password
878
  DebugEcho("POP3MessageFetch: message $i not an array");
879
  }
880
  } else {
881
- EchoInfo("POP3MessageFetch: message $i $pop3->ERROR");
882
  }
883
  if ($maxemails != 0 && $i >= $maxemails) {
884
  DebugEcho("Max emails ($maxemails)");
@@ -898,8 +900,11 @@ function PostToDB($details, $isReply, $customImageField, $postmodifiers) {
898
  if (!$isReply) {
899
  $post_ID = wp_insert_post($details, true);
900
  if (is_wp_error($post_ID)) {
901
- EchoInfo("Error: " . $post_ID->get_error_message());
 
 
902
  wp_delete_post($details['ID']);
 
903
  }
904
  //evidently post_category was depricated at some point.
905
  //wp_set_post_terms($post_ID, $details['post_category']);
@@ -957,7 +962,7 @@ function isBannedFileName($filename, $bannedFiles) {
957
  }
958
  foreach ($bannedFiles as $bannedFile) {
959
  if (fnmatch($bannedFile, $filename)) {
960
- EchoInfo("Ignoring attachment: $filename - it is on the banned files list.");
961
  return true;
962
  }
963
  }
@@ -1097,7 +1102,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1097
  $attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
1098
  DebugEcho("GetContent: text attachment: adding '$filename'");
1099
  } else {
1100
- do_action('postie_log_error', $file_id->get_error_message());
1101
  }
1102
  } else {
1103
  DebugEcho("GetContent: text attachment: skipping '$filename'");
@@ -1136,7 +1141,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1136
  $icon = chooseAttachmentIcon($file, $mimetype_primary, $mimetype_secondary, $config['icon_set'], $config['icon_size']);
1137
  $attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
1138
  } else {
1139
- do_action('postie_log_error', $file_id->get_error_message());
1140
  }
1141
  }
1142
  }
@@ -1172,7 +1177,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1172
  }
1173
  }
1174
  } else {
1175
- do_action('postie_log_error', "image error: " . $file_id->get_error_message());
1176
  }
1177
  break;
1178
 
@@ -1197,7 +1202,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1197
  }
1198
  $attachments["html"][$filename] = parseTemplate($file_id, $mimetype_primary, $audioTemplate, $filename);
1199
  } else {
1200
- do_action('postie_log_error', "audio error: " . $file_id->get_error_message());
1201
  }
1202
  break;
1203
 
@@ -1226,7 +1231,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1226
  $attachments["html"][$filename] = parseTemplate($file_id, $mimetype_primary, $videoTemplate, $filename);
1227
  //echo "videoTemplate = $videoTemplate\n";
1228
  } else {
1229
- do_action('postie_log_error', $file_id->get_error_message());
1230
  }
1231
  break;
1232
 
@@ -1254,7 +1259,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
1254
  DebugEcho("GetContent: No content-id");
1255
  }
1256
  } else {
1257
- do_action('postie_log_error', $file_id->get_error_message());
1258
  }
1259
  } else {
1260
  DebugEcho("GetContent: Not in supported filetype list");
@@ -1427,7 +1432,7 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
1427
  DebugEcho("ValidatePoster: looking up default user $admin_username");
1428
  $user = get_user_by('login', $admin_username);
1429
  if ($user === false) {
1430
- EchoInfo("Your 'Default Poster' setting '$admin_username' is not a valid WordPress user (2)");
1431
  $poster = 1;
1432
  } else {
1433
  $poster = $user->ID;
@@ -1441,13 +1446,13 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
1441
  $validSMTP = isValidSmtpServer($mimeDecodedEmail, $smtp);
1442
 
1443
  if (!$poster || !$validSMTP) {
1444
- EchoInfo('Invalid sender: ' . htmlentities($from) . "! Not adding email!");
1445
  if ($forward_rejected_mail) {
1446
  $admin_email = get_option("admin_email");
1447
- if (MailToRecipients($mimeDecodedEmail, false, array($admin_email), $return_to_sender)) {
1448
- EchoInfo("A copy of the message has been forwarded to the administrator.");
1449
  } else {
1450
- EchoInfo("The message was unable to be forwarded to the adminstrator.");
1451
  }
1452
  }
1453
  return '';
@@ -1472,7 +1477,7 @@ function isValidSmtpServer($mimeDecodedEmail, $smtpservers) {
1472
  }
1473
 
1474
  foreach ((array) $mimeDecodedEmail->headers['received'] as $received) {
1475
- EchoInfo("isValidSmtpServer: checking header $received");
1476
  foreach ($smtpservers as $smtp) {
1477
  if (stristr($received, $smtp) !== false) {
1478
  DebugEcho("isValidSmtpServer: Sent from valid SMTP server.");
@@ -1481,7 +1486,7 @@ function isValidSmtpServer($mimeDecodedEmail, $smtpservers) {
1481
  }
1482
  }
1483
 
1484
- EchoInfo("isValidSmtpServer: Sent from invalid SMTP server.");
1485
  return false;
1486
  }
1487
 
@@ -1815,7 +1820,6 @@ function filter_AppleFile(&$mimeDecodedEmail) {
1815
 
1816
  function postie_media_handle_upload($part, $post_id, $poster, $generate_thubnails = true, $mimetype_primary = null, $mimetype_secondary = null) {
1817
  $post_data = array();
1818
- $overrides = array('test_form' => false);
1819
 
1820
  $tmpFile = tempnam(get_temp_dir(), 'postie');
1821
  if ($tmpFile !== false) {
@@ -1824,10 +1828,10 @@ function postie_media_handle_upload($part, $post_id, $poster, $generate_thubnail
1824
  fwrite($fp, $part->body);
1825
  fclose($fp);
1826
  } else {
1827
- EchoInfo("postie_media_handle_upload: Could not write to temp file: '$tmpFile' ");
1828
  }
1829
  } else {
1830
- EchoInfo("postie_media_handle_upload: Could not create temp file in " . get_temp_dir());
1831
  }
1832
 
1833
  //special case to deal with older png implementations
@@ -1870,7 +1874,6 @@ function postie_media_handle_upload($part, $post_id, $poster, $generate_thubnail
1870
  $type = $part->primary . '/' . $part->secondary;
1871
  $the_file['ext'] = $ext;
1872
  $the_file['type'] = $type;
1873
- $overrides['test_type'] = false;
1874
  }
1875
 
1876
  $time = current_time('mysql');
@@ -1880,7 +1883,7 @@ function postie_media_handle_upload($part, $post_id, $poster, $generate_thubnail
1880
  $time = $post->post_date;
1881
  }
1882
 
1883
- $file = postie_handle_upload($the_file, $overrides, $time, $mimetype_primary, $mimetype_secondary);
1884
 
1885
 
1886
  if (isset($file['error'])) {
@@ -1940,13 +1943,15 @@ function postie_media_handle_upload($part, $post_id, $poster, $generate_thubnail
1940
  DebugEcho("thumbnail generation disabled");
1941
  }
1942
  } else {
1943
- EchoInfo("There was an error adding the attachement: " . $id->get_error_message());
 
 
1944
  }
1945
 
1946
  return $id;
1947
  }
1948
 
1949
- function postie_handle_upload(&$file, $overrides = false, $time = null, $mimetype_primary = null, $mimetype_secondary = null) {
1950
  // The default error handler.
1951
  if (!function_exists('wp_handle_upload_error')) {
1952
 
@@ -1966,6 +1971,9 @@ function postie_handle_upload(&$file, $overrides = false, $time = null, $mimetyp
1966
  } else if (!empty($mimetype_primary)) {
1967
  DebugEcho("postie_handle_upload: substituting mimetype_primary - $mimetype_primary/$mimetype_secondary");
1968
  $file['type'] = "$mimetype_primary/$mimetype_secondary";
 
 
 
1969
  }
1970
  }
1971
  DebugEcho("postie_handle_upload: detected file type for " . $file['name'] . " is " . $file['type']);
@@ -1988,14 +1996,14 @@ function postie_handle_upload(&$file, $overrides = false, $time = null, $mimetyp
1988
  __("Missing a temporary folder.", 'postie'),
1989
  __("Failed to write file to disk.", 'postie'));
1990
 
1991
- // Install user overrides. Did we mention that this voids your warranty?
1992
- if (is_array($overrides)) {
1993
- extract($overrides, EXTR_OVERWRITE);
1994
- }
1995
  // A successful upload will pass this test. It makes no sense to override this one.
1996
  if ($file['error'] > 0) {
1997
  return $upload_error_handler($file, $upload_error_strings[$file['error']]);
1998
  }
 
 
 
 
1999
  // A non-empty file will pass this test.
2000
  if (!($file['size'] > 0 )) {
2001
  return $upload_error_handler($file, __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.', 'postie'));
@@ -2124,11 +2132,8 @@ function filter_PreferedText($mimeDecodedEmail, $preferTextType) {
2124
  * This function can be used to send confirmation or rejection emails
2125
  * It accepts an object containing the entire message
2126
  */
2127
- function MailToRecipients(&$mail_content, $testEmail = false, $recipients = array(), $returnToSender = false, $reject = true, $postid = null) {
2128
  DebugEcho("MailToRecipients: send mail");
2129
- if ($testEmail) {
2130
- return false;
2131
- }
2132
 
2133
  $myemailadd = get_option("admin_email");
2134
  $blogname = get_option("blogname");
@@ -3309,7 +3314,7 @@ function HasFunctions($function_list, $display = true) {
3309
  foreach ($function_list as $function) {
3310
  if (!function_exists($function)) {
3311
  if ($display) {
3312
- EchoInfo("Missing $function");
3313
  }
3314
  return false;
3315
  }
@@ -3505,7 +3510,7 @@ function postie_test_config() {
3505
  <div class="wrap">
3506
  <h1>Postie Configuration Test</h1>
3507
  <?php
3508
- postie_environment();
3509
  ?>
3510
 
3511
  <h2>Clock Tests</h2>
@@ -3513,29 +3518,29 @@ function postie_test_config() {
3513
  <?php
3514
  $content = "";
3515
  $data = tag_Delay($content, null, $config['time_offset']);
3516
- EchoInfo("Post time: $data[0]");
3517
  ?>
3518
  <h2>Encoding</h2>
3519
  <?php
3520
- EchoInfo("default_charset: " . ini_get('default_charset'));
3521
  if (defined('DB_CHARSET')) {
3522
- EchoInfo("DB_CHARSET: " . DB_CHARSET);
3523
  } else {
3524
- EchoInfo("DB_CHARSET: undefined (utf8)");
3525
  }
3526
  if (defined('DB_COLLATE')) {
3527
- EchoInfo("DB_COLLATE: " . DB_COLLATE);
3528
  }
3529
- EchoInfo("WordPress encoding: " . esc_attr(get_option('blog_charset')));
3530
- EchoInfo("Postie encoding: " . $config['message_encoding']);
3531
  ?>
3532
  <h2>Connect to Mail Host</h2>
3533
 
3534
  <?php
3535
  if (!$config['mail_server'] || !$config['mail_server_port'] || !$config['mail_userid']) {
3536
- EchoInfo("FAIL - server settings not complete");
3537
  } else {
3538
- DebugEcho("checking");
3539
  }
3540
 
3541
  switch (strtolower($config["input_protocol"])) {
@@ -3543,7 +3548,7 @@ function postie_test_config() {
3543
  case 'imap-ssl':
3544
  case 'pop3-ssl':
3545
  if (!HasIMAPSupport()) {
3546
- EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting.");
3547
  } else {
3548
  require_once("postieIMAP.php");
3549
  $mail_server = &PostieIMAP::Factory($config["input_protocol"]);
@@ -3551,11 +3556,11 @@ function postie_test_config() {
3551
  $mail_server->TLSOn();
3552
  }
3553
  if (!$mail_server->connect($config["mail_server"], $config["mail_server_port"], $config["mail_userid"], $config["mail_password"])) {
3554
- EchoInfo("Unable to connect. The server said:");
3555
- EchoInfo($mail_server->error());
3556
  } else {
3557
- EchoInfo("Successful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}");
3558
- EchoInfo("# of waiting messages: " . $mail_server->getNumberOfMessages());
3559
  $mail_server->disconnect();
3560
  }
3561
  }
@@ -3568,9 +3573,9 @@ function postie_test_config() {
3568
  $pop3->DEBUG = POSTIE_DEBUG;
3569
  }
3570
  if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) {
3571
- EchoInfo("Unable to connect. The server said:" . $pop3->ERROR);
3572
  } else {
3573
- EchoInfo("Sucessful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}");
3574
  $msgs = $pop3->login($config["mail_userid"], $config["mail_password"]);
3575
  if ($msgs === false) {
3576
  //workaround for bug reported here Apr 12, 2013
@@ -3578,12 +3583,12 @@ function postie_test_config() {
3578
  //originally repoted here:
3579
  //https://core.trac.wordpress.org/ticket/10587
3580
  if (empty($pop3->ERROR)) {
3581
- EchoInfo("No waiting messages");
3582
  } else {
3583
- EchoInfo("Unable to login. The server said:" . $pop3->ERROR);
3584
  }
3585
  } else {
3586
- EchoInfo("# of waiting messages: $msgs");
3587
  }
3588
  $pop3->quit();
3589
  }
@@ -3608,7 +3613,8 @@ function postie_get_mail() {
3608
  add_action('postie_log_debug', 'postie_log_debug');
3609
  }
3610
 
3611
- EchoInfo("Starting mail fetch");
 
3612
  postie_environment();
3613
  $wp_content_path = dirname(dirname(dirname(__FILE__)));
3614
  DebugEcho("wp_content_path: $wp_content_path");
@@ -3617,6 +3623,8 @@ function postie_get_mail() {
3617
  include_once ($wp_content_path . DIRECTORY_SEPARATOR . "filterPostie.php");
3618
  }
3619
 
 
 
3620
  if (has_filter('postie_post')) {
3621
  echo "Postie: filter 'postie_post' is depricated in favor of 'postie_post_before'";
3622
  }
@@ -3626,10 +3634,10 @@ function postie_get_mail() {
3626
  $config['maxemails'] = 0;
3627
  }
3628
 
3629
- $emails = FetchMail($config['mail_server'], $config['mail_server_port'], $config['mail_userid'], $config['mail_password'], $config['input_protocol'], $config['time_offset'], $test_email, $config['delete_mail_after_processing'], $config['maxemails'], $config['email_tls']);
3630
  $message = 'Done.';
3631
 
3632
- EchoInfo(sprintf(__("There are %d messages to process", 'postie'), count($emails)));
3633
 
3634
  if (function_exists('memory_get_usage')) {
3635
  DebugEcho(__("memory at start of email processing:", 'postie') . memory_get_usage());
@@ -3642,14 +3650,15 @@ function postie_get_mail() {
3642
  foreach ($emails as $email) {
3643
  $message_number++;
3644
  DebugEcho("$message_number: ------------------------------------");
 
3645
  //sanity check to see if there is any info in the message
3646
  if ($email == NULL) {
3647
  $message = __('Dang, message is empty!', 'postie');
3648
- EchoInfo("$message_number: $message");
3649
  continue;
3650
- } else if (($config['ignore_mail_state'] == false) && ( $email == 'already read')) {
3651
  $message = __("Message is already marked 'read'.", 'postie');
3652
- EchoInfo("$message_number: $message");
3653
  continue;
3654
  }
3655
 
@@ -3661,13 +3670,14 @@ function postie_get_mail() {
3661
  $poster = ValidatePoster($mimeDecodedEmail, $config);
3662
  if (!empty($poster)) {
3663
  PostEmail($poster, $mimeDecodedEmail, $config);
3664
- EchoInfo("$message_number: processed");
3665
  } else {
3666
- EchoInfo("Ignoring email - not authorized.");
3667
  }
3668
  flush();
3669
  }
3670
- EchoInfo("Mail fetch complete, $message_number emails");
 
3671
 
3672
  if (function_exists('memory_get_usage')) {
3673
  DebugEcho("memory at end of email processing:" . memory_get_usage());
1
  <?php
2
  /*
3
+ $Id: postie-functions.php 1273489 2015-10-26 21:44:36Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
57
  }
58
  }
59
 
60
+ function postie_environment($force_display = false) {
61
+ DebugEcho("Postie Version: " . POSTIE_VERSION, $force_display);
62
+ DebugEcho("Wordpress Version: " . get_bloginfo('version'), $force_display);
63
+ DebugEcho("PHP Version: " . phpversion(), $force_display);
64
+ DebugEcho("OS: " . php_uname(), $force_display);
65
+ DebugEcho("POSTIE_DEBUG: " . (IsDebugMode() ? "On" : "Off"), $force_display);
66
+ DebugEcho("Time: " . date('Y-m-d H:i:s', time()) . " GMT", $force_display);
67
+ DebugEcho("Error log: " . ini_get('error_log'), $force_display);
68
+ DebugEcho("TMP dir: " . get_temp_dir(), $force_display);
69
+ DebugEcho("Postie is in " . plugin_dir_path(__FILE__), $force_display);
70
 
71
  if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
72
+ DebugEcho("Alternate cron is enabled", $force_display);
73
  }
74
 
75
  if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
76
+ DebugEcho("WordPress cron is disabled. Postie will not run unless you have an external cron set up.", $force_display);
77
  }
78
 
79
+ DebugEcho("Cron: " . (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON === true ? "Off" : "On"), $force_display);
80
+ DebugEcho("Alternate Cron: " . (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON === true ? "On" : "Off"), $force_display);
81
 
82
  if (defined('WP_CRON_LOCK_TIMEOUT') && WP_CRON_LOCK_TIMEOUT === true) {
83
+ DebugEcho("Cron lock timeout is:" . WP_CRON_LOCK_TIMEOUT, $force_display);
84
  }
85
  }
86
 
131
  error_log("Postie [debug]: $data");
132
  }
133
 
134
+ function EchoError($v) {
135
+ postie_log_error($v);
136
  do_action('postie_log_debug', $v);
137
  }
138
 
143
  do_action('postie_log_debug', print_r($v, true));
144
  }
145
 
146
+ function DebugEcho($v, $force = false) {
147
+ if ($force || (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG)) {
148
  postie_log_onscreen($v);
149
  }
150
  do_action('postie_log_debug', $v);
455
  // then it should be removed
456
  if (!$is_reply) {
457
  wp_delete_post($post_id);
458
+ EchoError("postie_post filter cleared the post, not saving.");
459
  }
460
  } else {
461
  DisplayEmailPost($details);
470
  } elseif ($confirmation_email == 'both') {
471
  $recipients = array($details['email_author'], get_option("admin_email"));
472
  }
473
+ if (null != $postid) {
474
+ MailToRecipients($mimeDecodedEmail, $recipients, false, false, $postid);
475
+ }
476
  }
477
  }
478
  } else {
479
+ EchoError("PostEmail wp_insert_post failed: " . $post_id->get_error_message());
480
  DebugDump($post_id->get_error_messages());
481
  DebugDump($post_id->get_error_data());
482
  }
759
  function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0, $email_tls = false) {
760
  $emails = array();
761
  if (!$server || !$port || !$email) {
762
+ EchoError("Missing Configuration For Mail Server");
763
  return $emails;
764
  }
765
  if ($server == "pop.gmail.com") {
766
+ EchoError("MAKE SURE POP IS TURNED ON IN SETTING AT Gmail");
767
  }
768
  switch (strtolower($protocol)) {
769
  case 'smtp': //direct
779
  case 'imap-ssl':
780
  case 'pop3-ssl':
781
  if (!HasIMAPSupport()) {
782
+ EchoError("Sorry - you do not have IMAP php module installed - it is required for this mail setting.");
783
  } else {
784
  $emails = IMAPMessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages, $maxemails, $email_tls);
785
  }
795
  /**
796
  * Handles fetching messages from an imap server
797
  */
798
+ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0, $tls = false, $ignoreMailState = true) {
799
  require_once("postieIMAP.php");
800
  $emails = array();
801
  $mail_server = &PostieIMAP::Factory($protocol);
806
  if ($mail_server->connect(trim($server), $port, $email, $password)) {
807
  $msg_count = $mail_server->getNumberOfMessages();
808
  } else {
809
+ EchoError("Mail Connection Time Out");
810
+ EchoError("Common Reasons: Server Down, Network Issue, Port/Protocol MisMatch ");
811
+ EchoError("The Server said:" . $mail_server->error());
812
  $msg_count = 0;
813
  }
814
 
815
  // loop through messages
816
  for ($i = 1; $i <= $msg_count; $i++) {
817
+ $emails[$i] = $mail_server->fetchEmail($i, $ignoreMailState);
818
  if ($deleteMessages) {
819
  $mail_server->deleteMessage($i);
820
  }
852
  }
853
  } else {
854
  if (strpos($pop3->ERROR, "POP3: premature NOOP OK, NOT an RFC 1939 Compliant server") === false) {
855
+ EchoError("Mail Connection Time Out. Common Reasons: Server Down, Network Issue, Port/Protocol MisMatch");
856
  }
857
+ EchoError("The Server said: $pop3->ERROR");
858
  $msg_count = 0;
859
  }
860
  DebugEcho("message count: $msg_count");
871
  $emails[$i] = implode('', $m);
872
  if ($deleteMessages) {
873
  if (!$pop3->delete($i)) {
874
+ EchoError("POP3MessageFetch: cannot delete message $i: " . $pop3->ERROR);
875
  $pop3->reset();
876
  exit;
877
  }
880
  DebugEcho("POP3MessageFetch: message $i not an array");
881
  }
882
  } else {
883
+ EchoError("POP3MessageFetch: message $i $pop3->ERROR");
884
  }
885
  if ($maxemails != 0 && $i >= $maxemails) {
886
  DebugEcho("Max emails ($maxemails)");
900
  if (!$isReply) {
901
  $post_ID = wp_insert_post($details, true);
902
  if (is_wp_error($post_ID)) {
903
+ EchoError("PostToDB Error: " . $post_ID->get_error_message());
904
+ DebugDump($post_ID->get_error_messages());
905
+ DebugDump($post_ID->get_error_data());
906
  wp_delete_post($details['ID']);
907
+ $post_ID = null;
908
  }
909
  //evidently post_category was depricated at some point.
910
  //wp_set_post_terms($post_ID, $details['post_category']);
962
  }
963
  foreach ($bannedFiles as $bannedFile) {
964
  if (fnmatch($bannedFile, $filename)) {
965
+ EchoError("Ignoring attachment: $filename - it is on the banned files list.");
966
  return true;
967
  }
968
  }
1102
  $attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
1103
  DebugEcho("GetContent: text attachment: adding '$filename'");
1104
  } else {
1105
+ EchoError($file_id->get_error_message());
1106
  }
1107
  } else {
1108
  DebugEcho("GetContent: text attachment: skipping '$filename'");
1141
  $icon = chooseAttachmentIcon($file, $mimetype_primary, $mimetype_secondary, $config['icon_set'], $config['icon_size']);
1142
  $attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
1143
  } else {
1144
+ EchoError($file_id->get_error_message());
1145
  }
1146
  }
1147
  }
1177
  }
1178
  }
1179
  } else {
1180
+ EchoError("image error: " . $file_id->get_error_message());
1181
  }
1182
  break;
1183
 
1202
  }
1203
  $attachments["html"][$filename] = parseTemplate($file_id, $mimetype_primary, $audioTemplate, $filename);
1204
  } else {
1205
+ EchoError("audio error: " . $file_id->get_error_message());
1206
  }
1207
  break;
1208
 
1231
  $attachments["html"][$filename] = parseTemplate($file_id, $mimetype_primary, $videoTemplate, $filename);
1232
  //echo "videoTemplate = $videoTemplate\n";
1233
  } else {
1234
+ EchoError($file_id->get_error_message());
1235
  }
1236
  break;
1237
 
1259
  DebugEcho("GetContent: No content-id");
1260
  }
1261
  } else {
1262
+ EchoError($file_id->get_error_message());
1263
  }
1264
  } else {
1265
  DebugEcho("GetContent: Not in supported filetype list");
1432
  DebugEcho("ValidatePoster: looking up default user $admin_username");
1433
  $user = get_user_by('login', $admin_username);
1434
  if ($user === false) {
1435
+ EchoError("Your 'Default Poster' setting '$admin_username' is not a valid WordPress user (2)");
1436
  $poster = 1;
1437
  } else {
1438
  $poster = $user->ID;
1446
  $validSMTP = isValidSmtpServer($mimeDecodedEmail, $smtp);
1447
 
1448
  if (!$poster || !$validSMTP) {
1449
+ EchoError('Invalid sender: ' . htmlentities($from) . "! Not adding email!");
1450
  if ($forward_rejected_mail) {
1451
  $admin_email = get_option("admin_email");
1452
+ if (MailToRecipients($mimeDecodedEmail, array($admin_email), $return_to_sender)) {
1453
+ EchoError("A copy of the message has been forwarded to the administrator.");
1454
  } else {
1455
+ EchoError("The message was unable to be forwarded to the adminstrator.");
1456
  }
1457
  }
1458
  return '';
1477
  }
1478
 
1479
  foreach ((array) $mimeDecodedEmail->headers['received'] as $received) {
1480
+ EchoError("isValidSmtpServer: checking header $received");
1481
  foreach ($smtpservers as $smtp) {
1482
  if (stristr($received, $smtp) !== false) {
1483
  DebugEcho("isValidSmtpServer: Sent from valid SMTP server.");
1486
  }
1487
  }
1488
 
1489
+ EchoError("isValidSmtpServer: Sent from invalid SMTP server.");
1490
  return false;
1491
  }
1492
 
1820
 
1821
  function postie_media_handle_upload($part, $post_id, $poster, $generate_thubnails = true, $mimetype_primary = null, $mimetype_secondary = null) {
1822
  $post_data = array();
 
1823
 
1824
  $tmpFile = tempnam(get_temp_dir(), 'postie');
1825
  if ($tmpFile !== false) {
1828
  fwrite($fp, $part->body);
1829
  fclose($fp);
1830
  } else {
1831
+ EchoError("postie_media_handle_upload: Could not write to temp file: '$tmpFile' ");
1832
  }
1833
  } else {
1834
+ EchoError("postie_media_handle_upload: Could not create temp file in " . get_temp_dir());
1835
  }
1836
 
1837
  //special case to deal with older png implementations
1874
  $type = $part->primary . '/' . $part->secondary;
1875
  $the_file['ext'] = $ext;
1876
  $the_file['type'] = $type;
 
1877
  }
1878
 
1879
  $time = current_time('mysql');
1883
  $time = $post->post_date;
1884
  }
1885
 
1886
+ $file = postie_handle_upload($the_file, $time, $mimetype_primary, $mimetype_secondary);
1887
 
1888
 
1889
  if (isset($file['error'])) {
1943
  DebugEcho("thumbnail generation disabled");
1944
  }
1945
  } else {
1946
+ EchoError("There was an error adding the attachement: " . $id->get_error_message());
1947
+ DebugDump($id->get_error_messages());
1948
+ DebugDump($id->get_error_data());
1949
  }
1950
 
1951
  return $id;
1952
  }
1953
 
1954
+ function postie_handle_upload(&$file, $time = null, $mimetype_primary = null, $mimetype_secondary = null) {
1955
  // The default error handler.
1956
  if (!function_exists('wp_handle_upload_error')) {
1957
 
1971
  } else if (!empty($mimetype_primary)) {
1972
  DebugEcho("postie_handle_upload: substituting mimetype_primary - $mimetype_primary/$mimetype_secondary");
1973
  $file['type'] = "$mimetype_primary/$mimetype_secondary";
1974
+ } else {
1975
+ DebugEcho("postie_handle_upload: no type found, implies not allowed");
1976
+ $file['type'] = '';
1977
  }
1978
  }
1979
  DebugEcho("postie_handle_upload: detected file type for " . $file['name'] . " is " . $file['type']);
1996
  __("Missing a temporary folder.", 'postie'),
1997
  __("Failed to write file to disk.", 'postie'));
1998
 
 
 
 
 
1999
  // A successful upload will pass this test. It makes no sense to override this one.
2000
  if ($file['error'] > 0) {
2001
  return $upload_error_handler($file, $upload_error_strings[$file['error']]);
2002
  }
2003
+ // A file with a valid mime type
2004
+ if (empty($file['type'])) {
2005
+ return $upload_error_handler($file, __('File type is not allowed', 'postie'));
2006
+ }
2007
  // A non-empty file will pass this test.
2008
  if (!($file['size'] > 0 )) {
2009
  return $upload_error_handler($file, __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.', 'postie'));
2132
  * This function can be used to send confirmation or rejection emails
2133
  * It accepts an object containing the entire message
2134
  */
2135
+ function MailToRecipients(&$mail_content, $recipients = array(), $returnToSender = false, $reject = true, $postid = null) {
2136
  DebugEcho("MailToRecipients: send mail");
 
 
 
2137
 
2138
  $myemailadd = get_option("admin_email");
2139
  $blogname = get_option("blogname");
3314
  foreach ($function_list as $function) {
3315
  if (!function_exists($function)) {
3316
  if ($display) {
3317
+ EchoError("Missing $function");
3318
  }
3319
  return false;
3320
  }
3510
  <div class="wrap">
3511
  <h1>Postie Configuration Test</h1>
3512
  <?php
3513
+ postie_environment(true);
3514
  ?>
3515
 
3516
  <h2>Clock Tests</h2>
3518
  <?php
3519
  $content = "";
3520
  $data = tag_Delay($content, null, $config['time_offset']);
3521
+ DebugEcho("Post time: $data[0]", true);
3522
  ?>
3523
  <h2>Encoding</h2>
3524
  <?php
3525
+ DebugEcho("default_charset: " . ini_get('default_charset'), true);
3526
  if (defined('DB_CHARSET')) {
3527
+ DebugEcho("DB_CHARSET: " . DB_CHARSET, true);
3528
  } else {
3529
+ DebugEcho("DB_CHARSET: undefined (utf8)", true);
3530
  }
3531
  if (defined('DB_COLLATE')) {
3532
+ DebugEcho("DB_COLLATE: " . DB_COLLATE, true);
3533
  }
3534
+ DebugEcho("WordPress encoding: " . esc_attr(get_option('blog_charset')), true);
3535
+ DebugEcho("Postie encoding: " . $config['message_encoding'], true);
3536
  ?>
3537
  <h2>Connect to Mail Host</h2>
3538
 
3539
  <?php
3540
  if (!$config['mail_server'] || !$config['mail_server_port'] || !$config['mail_userid']) {
3541
+ EchoError("FAIL - server settings not complete");
3542
  } else {
3543
+ DebugEcho("checking", true);
3544
  }
3545
 
3546
  switch (strtolower($config["input_protocol"])) {
3548
  case 'imap-ssl':
3549
  case 'pop3-ssl':
3550
  if (!HasIMAPSupport()) {
3551
+ EchoError("Sorry - you do not have IMAP php module installed - it is required for this mail setting.");
3552
  } else {
3553
  require_once("postieIMAP.php");
3554
  $mail_server = &PostieIMAP::Factory($config["input_protocol"]);
3556
  $mail_server->TLSOn();
3557
  }
3558
  if (!$mail_server->connect($config["mail_server"], $config["mail_server_port"], $config["mail_userid"], $config["mail_password"])) {
3559
+ EchoError("Unable to connect. The server said:");
3560
+ EchoError($mail_server->error());
3561
  } else {
3562
+ DebugEcho("Successful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}", true);
3563
+ DebugEcho("# of waiting messages: " . $mail_server->getNumberOfMessages(), true);
3564
  $mail_server->disconnect();
3565
  }
3566
  }
3573
  $pop3->DEBUG = POSTIE_DEBUG;
3574
  }
3575
  if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) {
3576
+ EchoError("Unable to connect. The server said:" . $pop3->ERROR);
3577
  } else {
3578
+ DebugEcho("Sucessful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}", true);
3579
  $msgs = $pop3->login($config["mail_userid"], $config["mail_password"]);
3580
  if ($msgs === false) {
3581
  //workaround for bug reported here Apr 12, 2013
3583
  //originally repoted here:
3584
  //https://core.trac.wordpress.org/ticket/10587
3585
  if (empty($pop3->ERROR)) {
3586
+ DebugEcho("No waiting messages", true);
3587
  } else {
3588
+ EchoError("Unable to login. The server said:" . $pop3->ERROR);
3589
  }
3590
  } else {
3591
+ DebugEcho("# of waiting messages: $msgs", true);
3592
  }
3593
  $pop3->quit();
3594
  }
3613
  add_action('postie_log_debug', 'postie_log_debug');
3614
  }
3615
 
3616
+ DebugEcho("Starting mail fetch");
3617
+
3618
  postie_environment();
3619
  $wp_content_path = dirname(dirname(dirname(__FILE__)));
3620
  DebugEcho("wp_content_path: $wp_content_path");
3623
  include_once ($wp_content_path . DIRECTORY_SEPARATOR . "filterPostie.php");
3624
  }
3625
 
3626
+ do_action('postie_session_start');
3627
+
3628
  if (has_filter('postie_post')) {
3629
  echo "Postie: filter 'postie_post' is depricated in favor of 'postie_post_before'";
3630
  }
3634
  $config['maxemails'] = 0;
3635
  }
3636
 
3637
+ $emails = FetchMail($config['mail_server'], $config['mail_server_port'], $config['mail_userid'], $config['mail_password'], $config['input_protocol'], $config['time_offset'], $test_email, $config['delete_mail_after_processing'], $config['maxemails'], $config['email_tls'], $config['ignore_mail_state']);
3638
  $message = 'Done.';
3639
 
3640
+ DebugEcho(sprintf(__("There are %d messages to process", 'postie'), count($emails)));
3641
 
3642
  if (function_exists('memory_get_usage')) {
3643
  DebugEcho(__("memory at start of email processing:", 'postie') . memory_get_usage());
3650
  foreach ($emails as $email) {
3651
  $message_number++;
3652
  DebugEcho("$message_number: ------------------------------------");
3653
+ //DebugDump($email);
3654
  //sanity check to see if there is any info in the message
3655
  if ($email == NULL) {
3656
  $message = __('Dang, message is empty!', 'postie');
3657
+ EchoError("$message_number: $message");
3658
  continue;
3659
+ } else if ($email == 'already read') {
3660
  $message = __("Message is already marked 'read'.", 'postie');
3661
+ EchoError("$message_number: $message");
3662
  continue;
3663
  }
3664
 
3670
  $poster = ValidatePoster($mimeDecodedEmail, $config);
3671
  if (!empty($poster)) {
3672
  PostEmail($poster, $mimeDecodedEmail, $config);
3673
+ DebugEcho("$message_number: processed");
3674
  } else {
3675
+ EchoError("Ignoring email - not authorized.");
3676
  }
3677
  flush();
3678
  }
3679
+ DebugEcho("Mail fetch complete, $message_number emails");
3680
+ do_action('postie_session_end');
3681
 
3682
  if (function_exists('memory_get_usage')) {
3683
  DebugEcho("memory at end of email processing:" . memory_get_usage());
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Signifigantly upgrades the Post by Email features of Word Press.
7
- Version: 1.7.18
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
@@ -28,12 +28,12 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 1265241 2015-10-13 20:16:04Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
35
 
36
- define('POSTIE_VERSION', '1.7.18');
37
  define("POSTIE_ROOT", dirname(__FILE__));
38
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
39
 
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Signifigantly upgrades the Post by Email features of Word Press.
7
+ Version: 1.7.20
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
28
  */
29
 
30
  /*
31
+ $Id: postie.php 1273489 2015-10-26 21:44:36Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
35
 
36
+ define('POSTIE_VERSION', '1.7.20');
37
  define("POSTIE_ROOT", dirname(__FILE__));
38
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
39
 
postieIMAP.php CHANGED
@@ -93,7 +93,7 @@ class PostieIMAP {
93
  $this->_connected = true;
94
  DebugEcho($this->_protocol . ": connected");
95
  } else {
96
- do_action('postie_log_error', "imap_open failed: " . imap_last_error());
97
  }
98
  return $this->_connected;
99
  }
@@ -108,7 +108,7 @@ class PostieIMAP {
108
  if ($status) {
109
  return max($status->messages, imap_num_msg($this->_connection));
110
  } else {
111
- do_action('postie_log_error', "Error imap_status did not return a value");
112
  //DebugDump($this);
113
  return 0;
114
  }
@@ -118,12 +118,12 @@ class PostieIMAP {
118
  * Gets the raw email message from the server
119
  * @return string
120
  */
121
- function fetchEmail($index) {
122
 
123
  $header_info = imap_headerinfo($this->_connection, $index);
124
  //DebugDump($header_info);
125
 
126
- if (IsDebugMode() || $header_info->Recent == 'N' || $header_info->Unseen == 'U') {
127
  $email = imap_fetchheader($this->_connection, $index);
128
  $email .= imap_body($this->_connection, $index);
129
 
93
  $this->_connected = true;
94
  DebugEcho($this->_protocol . ": connected");
95
  } else {
96
+ EchoError("imap_open failed: " . imap_last_error());
97
  }
98
  return $this->_connected;
99
  }
108
  if ($status) {
109
  return max($status->messages, imap_num_msg($this->_connection));
110
  } else {
111
+ EchoError("Error imap_status did not return a value");
112
  //DebugDump($this);
113
  return 0;
114
  }
118
  * Gets the raw email message from the server
119
  * @return string
120
  */
121
+ function fetchEmail($index, $ignoreMailState) {
122
 
123
  $header_info = imap_headerinfo($this->_connection, $index);
124
  //DebugDump($header_info);
125
 
126
+ if (true == $ignoreMailState || IsDebugMode() || $header_info->Recent == 'N' || $header_info->Unseen == 'U') {
127
  $email = imap_fetchheader($this->_connection, $index);
128
  $email .= imap_body($this->_connection, $index);
129
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.3.1
9
- Stable tag: 1.7.18
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -235,6 +235,15 @@ All script, style and body tags are stripped from html emails.
235
  Attachments are now processed in the order they were attached.
236
 
237
  == CHANGELOG ==
 
 
 
 
 
 
 
 
 
238
  = 1.7.18 (2015-10-13) =
239
  * Fix bug where linkify was messing up CID reference
240
 
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.3.1
9
+ Stable tag: 1.7.20
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
235
  Attachments are now processed in the order they were attached.
236
 
237
  == CHANGELOG ==
238
+ = 1.7.20 (2015-10-26) =
239
+ * Fixed bug where debug info was not being displayed according to settings
240
+ * Fix bug where "Ignore mail state" setting was being ignored
241
+ * Fix bug where empty post was being generated when already read mail was in the inbox and "Ignore mail state" was "Yes"
242
+ * Added postie_session_start and postie_session_end actions
243
+
244
+ = 1.7.19 (2015-10-13) =
245
+ * Fixed bug where allowed mime types was not being respected.
246
+
247
  = 1.7.18 (2015-10-13) =
248
  * Fix bug where linkify was messing up CID reference
249