function PostiePOP3SSL($protocol = "pop3", $ssl_on = true, $self_cert = true) { PostieIMAP::PostieIMAP($protocol, $ssl_on, $self_cert); }
/** * Handles fetching messages from an imap server */ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0, $tls = false) { require_once "postieIMAP.php"; $emails = array(); $mail_server =& PostieIMAP::Factory($protocol); if ($tls) { $mail_server->TLSOn(); } DebugEcho("Connecting to {$server}:{$port} ({$protocol})" . ($tls ? " with TLS" : "")); if ($mail_server->connect(trim($server), $port, $email, $password)) { $msg_count = $mail_server->getNumberOfMessages(); } else { EchoInfo("Mail Connection Time Out"); EchoInfo("Common Reasons: Server Down, Network Issue, Port/Protocol MisMatch "); EchoInfo("The Server said:" . $mail_server->error()); $msg_count = 0; } // loop through messages for ($i = 1; $i <= $msg_count; $i++) { $emails[$i] = $mail_server->fetchEmail($i); if ($deleteMessages) { $mail_server->deleteMessage($i); } if ($maxemails != 0 && $i >= $maxemails) { DebugEcho("Max emails ({$maxemails})"); break; } } if ($deleteMessages) { $mail_server->expungeMessages(); } //clean up $mail_server->disconnect(); return $emails; }
/** *Handles fetching messages from an imap server */ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true) { require_once "postieIMAP.php"; $mail_server =& PostieIMAP::Factory($protocol); print "\nConnecting to {$server}:{$port} ({$protocol}) \n"; if (!$mail_server->connect($server, $port, $email, $password)) { print "Mail Connection Time Out\n\n Common Reasons: \n\n Server Down \n\n Network Issue \n\n Port/Protocol MisMatch \n\n "; die("The Server said:" . $mail_server->error() . "\n"); } $msg_count = $mail_server->getNumberOfMessages(); $emails = array(); // loop through messages for ($i = 1; $i <= $msg_count; $i++) { $emails[$i] = $mail_server->fetchEmail($i); if ($deleteMessages) { $mail_server->deleteMessage($i); } } if ($deleteMessages) { $mail_server->expungeMessages(); } //clean up $mail_server->disconnect(); return $emails; }
<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'; $pop3 =& new POP3(); if (!$pop3->connect($config["MAIL_SERVER"], $config["MAIL_SERVER_PORT"])) { print "Unable to connect. The server said - " . $pop3->ERROR; print "<br/>Try putting in your full email address as a userid and try again.";
<?php if (!$mail_server || !$mail_server_port || !$mail_userid) { EchoInfo("NO - check server settings"); } 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()); } } break; case 'pop3': default: require_once ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php';
/** *Handles fetching messages from an imap server */ function IMAPMessageFetch($config = NULL) { if (!$config) { $config = GetConfig(); } require_once "postieIMAP.php"; $mail_server =& PostieIMAP::Factory($config["INPUT_PROTOCOL"]); print "\nConnecting to {$config['MAIL_SERVER']}:{$config['MAIL_SERVER_PORT']} ({$config['INPUT_PROTOCOL']})) \n"; if (!$mail_server->connect($config["MAIL_SERVER"], $config["MAIL_SERVER_PORT"], $config["MAIL_USERID"], $config["MAIL_PASSWORD"])) { print "Mail Connection Time Out\n\n Common Reasons: \n\n Server Down \n\n Network Issue \n\n Port/Protocol MisMatch \n\n "; die("The Server said:" . $mail_server->error() . "\n"); } $msg_count = $mail_server->getNumberOfMessages(); $emails = array(); // loop through messages for ($i = 1; $i <= $msg_count; $i++) { $emails[$i] = $mail_server->fetchEmail($i); if ($config["DELETE_MAIL_AFTER_PROCESSING"]) { $mail_server->deleteMessage($i); } else { print "Not deleting messages!\n"; } } if ($config["DELETE_MAIL_AFTER_PROCESSING"]) { $mail_server->expungeMessages(); } //clean up $mail_server->disconnect(); 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 }