/** * This function handles determining the protocol and fetching the mail * @return array */ function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0, $email_tls = false) { $emails = array(); if (!$server || !$port || !$email) { EchoInfo("Missing Configuration For Mail Server"); return $emails; } if ($server == "pop.gmail.com") { EchoInfo("MAKE SURE POP IS TURNED ON IN SETTING AT Gmail"); } switch (strtolower($protocol)) { case 'smtp': //direct $fd = fopen("php://stdin", "r"); $input = ""; while (!feof($fd)) { $input .= fread($fd, 1024); } fclose($fd); $emails[0] = $input; break; case 'imap': case 'imap-ssl': case 'pop3-ssl': if (!HasIMAPSupport()) { EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting."); } else { $emails = IMAPMessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages, $maxemails, $email_tls); } break; case 'pop3': default: $emails = POP3MessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages, $maxemails); } return $emails; }
/** * This function handles determining the protocol and fetching the mail * @return array */ function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true) { $emails = array(); if (!$server || !$port || !$email) { die("Missing Configuration For Mail Server\n"); } if ($server == "pop.gmail.com") { print "\nMAKE SURE POP IS TURNED ON IN SETTING AT Gmail\n"; } switch (strtolower($protocol)) { case 'smtp': //direct $fd = fopen("php://stdin", "r"); $input = ""; while (!feof($fd)) { $input .= fread($fd, 1024); } fclose($fd); $emails[0] = $input; break; case 'imap': case 'imap-ssl': case 'pop3-ssl': HasIMAPSupport(false); if ($test) { $emails = TestIMAPMessageFetch(); } else { $emails = IMAPMessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages); } break; case 'pop3': default: if ($test) { $emails = TestPOP3MessageFetch(); } else { $emails = POP3MessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages); } } if (!$emails) { //die("\n" . __('There does not seem to be any new mail.', 'postie') . "\n"); $emails = false; } return $emails; }
?> >IMAP</option> <option value="pop3-ssl" <?php echo $input_protocol == "pop3-ssl" ? "selected='selected' " : ""; ?> >POP3-SSL</option> <option value="imap-ssl" <?php echo $input_protocol == "imap-ssl" ? "selected='selected' " : ""; ?> >IMAP-SSL</option> <?php } ?> </select> <?php if (!HasIMAPSupport(false)) { ?> <span class="recommendation">IMAP/IMAP-SSL/POP3-SSL unavailable</span> <?php } ?> </td> </tr> <?php echo BuildBooleanSelect(__("Use Transport Layer Security (TLS)"), 'postie-settings[email_tls]', $email_tls, __("Choose Yes if your server requres TLS")); ?> <tr> <th scope="row"><?php _e('Port:', 'postie');
<p>These try to confirm that the email configuration is correct.</p> <table> <tr> <th>Test</th> <th>Result</th> </tr> <tr> <th>Connect to Mail Host</th> <td> <?php switch (strtolower($config["INPUT_PROTOCOL"])) { case 'imap': case 'imap-ssl': case 'pop3-ssl': if (!HasIMAPSupport()) { print "Sorry - you do not have IMAP php module installed - it is required for this mail setting."; } else { require_once "postieIMAP.php"; $mail_server =& PostieIMAP::Factory($config["INPUT_PROTOCOL"]); if (!$mail_server->connect($config["MAIL_SERVER"], $config["MAIL_SERVER_PORT"], $config["MAIL_USERID"], $config["MAIL_PASSWORD"])) { print "Unable to connect. The server said - " . $mail_server->error(); print "<br/>Try putting in your full email address as a userid and try again."; } else { print "Yes"; } } break; case 'pop3': default: require_once ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php';
/** * This function handles determining the protocol and fetching the mail * @return array */ function FetchMail() { $config = GetConfig(); $emails = array(); if (!$config["MAIL_SERVER"] || !$config["MAIL_SERVER_PORT"] || !$config["MAIL_USERID"]) { die("Missing Configuration For Mail Server\n"); } if ($config["MAIL_SERVER"] == "pop.gmail.com") { print "\nMAKE SURE POP IS TURNED ON IN SETTING AT Gmail\n"; } switch (strtolower($config["INPUT_PROTOCOL"])) { case 'smtp': //direct $fd = fopen("php://stdin", "r"); $input = ""; while (!feof($fd)) { $input .= fread($fd, 1024); } fclose($fd); $emails[0] = $input; break; case 'imap': case 'imap-ssl': case 'pop3-ssl': HasIMAPSupport(false); if ($config["TEST_EMAIL"]) { $emails = TestIMAPMessageFetch(); } else { $emails = IMAPMessageFetch(); } break; case 'pop3': default: if ($config["TEST_EMAIL"]) { $emails = TestPOP3MessageFetch(); } else { $emails = POP3MessageFetch(); } } if (!$emails) { die("\nThere does not seem to be any new mail.\n"); } return $emails; }
function postie_test_config() { $config = config_Read(); extract($config); get_currentuserinfo(); if (!current_user_can('manage_options')) { LogInfo("non-admin tried to set options"); echo "<h2> Sorry only admin can run this file</h2>"; exit; } ?> <div class="wrap"> <h1>Postie Configuration Test</h1> <?php postie_environment(); ?> <h2>Clock Tests</h2> <p>This shows what time it would be if you posted right now</p> <?php $content = ""; $data = filter_Delay($content, null, $config['time_offset']); EchoInfo("Post time: {$data['0']}"); ?> <h2>Connect to Mail Host</h2> <?php if (!$mail_server || !$mail_server_port || !$mail_userid) { EchoInfo("FAIL - server settings not complete"); } else { DebugEcho("checking"); } switch (strtolower($config["input_protocol"])) { case 'imap': case 'imap-ssl': case 'pop3-ssl': if (!HasIMAPSupport()) { EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting."); } else { require_once "postieIMAP.php"; $mail_server =& PostieIMAP::Factory($config["input_protocol"]); if ($email_tls) { $mail_server->TLSOn(); } if (!$mail_server->connect($config["mail_server"], $config["mail_server_port"], $config["mail_userid"], $config["mail_password"])) { EchoInfo("Unable to connect. The server said:"); EchoInfo($mail_server->error()); } else { EchoInfo("Successful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}"); EchoInfo("# of waiting messages: " . $mail_server->getNumberOfMessages()); $mail_server->disconnect(); } } break; case 'pop3': default: require_once ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php'; $pop3 = new POP3(); if (defined('POSTIE_DEBUG')) { $pop3->DEBUG = POSTIE_DEBUG; } if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) { EchoInfo("Unable to connect. The server said:" . $pop3->ERROR); } else { EchoInfo("Sucessful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}"); $msgs = $pop3->login($config["mail_userid"], $config["mail_password"]); if ($msgs === false) { //workaround for bug reported here Apr 12, 2013 //https://sourceforge.net/tracker/?func=detail&atid=100311&aid=3610701&group_id=311 //originally repoted here: //https://core.trac.wordpress.org/ticket/10587 if (empty($pop3->ERROR)) { EchoInfo("No waiting messages"); } else { EchoInfo("Unable to login. The server said:" . $pop3->ERROR); } } else { EchoInfo("# of waiting messages: {$msgs}"); } $pop3->quit(); } break; } ?> </div> <?php }