Version 5.2.4
Author: Richard Davey (orig) (rich@corephp.co.uk)
Author: Andy Prevost
Author: Jim Jagielski
示例#1
0
function zenphoto_PHPMailer($msg, $email_list, $subject, $message, $from_mail, $from_name, $cc_addresses, $replyTo, $html = false)
{
    require_once dirname(__FILE__) . '/PHPMailer/class.phpmailer.php';
    switch (getOption('PHPMailer_mail_protocol')) {
        case 'pop3':
            require_once dirname(__FILE__) . '/PHPMailer/class.pop3.php';
            $pop = new POP3();
            $authorized = $pop->Authorise(getOption('PHPMailer_server'), getOption('PHPMailer_pop_port'), 30, getOption('PHPMailer_user'), getOption('PHPMailer_password'), 0);
            $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->Port = getOption('PHPMailer_smtp_port');
            $mail->Host = getOption('PHPMailer_server');
            break;
        case 'smtp':
            $mail = new PHPMailer();
            $mail->SMTPAuth = true;
            // enable SMTP authentication
            $mail->IsSMTP();
            $mail->Username = getOption('PHPMailer_user');
            $mail->Password = getOption('PHPMailer_password');
            $mail->Host = getOption('PHPMailer_server');
            $mail->Port = getOption('PHPMailer_smtp_port');
            break;
        case 'sendmail':
            $mail = new PHPMailer();
            $mail->IsSendmail();
            break;
    }
    $mail->SMTPSecure = getOption('PHPMailer_secure');
    $mail->CharSet = 'UTF-8';
    $mail->From = $from_mail;
    $mail->FromName = $from_name;
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->AltBody = '';
    $mail->IsHTML($html);
    foreach ($email_list as $to_name => $to_mail) {
        if (is_numeric($to_name)) {
            $mail->AddAddress($to_mail);
        } else {
            $mail->AddAddress($to_mail, $to_name);
        }
    }
    if (count($cc_addresses) > 0) {
        foreach ($cc_addresses as $cc_name => $cc_mail) {
            $mail->AddCC($cc_mail);
        }
    }
    if ($replyTo) {
        $names = array_keys($replyTo);
        $mail->AddReplyTo(array_shift($replyTo), array_shift($names));
    }
    if (!$mail->Send()) {
        if (!empty($msg)) {
            $msg .= '<br />';
        }
        $msg .= sprintf(gettext('<code>PHPMailer</code> failed to send <em>%1$s</em>. ErrorInfo:%2$s'), $subject, $mail->ErrorInfo);
    }
    return $msg;
}
示例#2
0
 function SendMail($toAddress, $toName, $subject, $messageBody, $bcc = NULL, $mailList = FALSE)
 {
     require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/Main.php";
     if ($mailList) {
         require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService2.php";
     } else {
         require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService.php";
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.phpmailer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.pop3.php";
     if ($MailServiceAuthPOP3) {
         $pop = new POP3();
         $pop->Authorise($MailServicePOP3Addr, $MailServicePOP3Port, 30, $MailServiceSMTPUser, $MailServiceSMTPPass, $MailServicePOPDebug);
     }
     $mail = new PHPMailer();
     if ($MailServiceMailerLang != "en") {
         $mail->SetLanguage($MailServiceMailerLang, $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/language/");
     }
     $mail->IsSMTP();
     $mail->SMTPDebug = $MailServiceSMTPDebug;
     $mail->Port = $MailServiceSMTPPort;
     $mail->SMTPSecure = $MailServiceEncrypt;
     $mail->Host = $MailServiceSMTPAddr;
     $mail->SMTPAuth = $MailServiceAuthSMTP;
     $mail->Username = $MailServiceSMTPUser;
     $mail->Password = $MailServiceSMTPPass;
     $mail->From = $MailServiceFromMail;
     $mail->FromName = $MailServiceFromName;
     $mail->AddAddress($toAddress, $toName);
     if ($bcc != NULL) {
         if (is_array($bcc)) {
             foreach ($bcc as $key => $value) {
                 $mail->AddBCC($value);
             }
         }
     }
     $mail->WordWrap = 50;
     $mail->CharSet = $MailServiceMsgCharset;
     $mail->IsHTML(true);
     $mail->Subject = $subject;
     $mail->Body = $messageBody;
     if ($mail->Send()) {
         return true;
     } else {
         return $mail->ErrorInfo;
     }
 }
示例#3
0
function sendMail($_msubject, $_mbody, $_mto, $_mname)
{
    global $SMTP_FROMNAME;
    $pop = new POP3();
    $pop->Authorise('envasadoras.com.mx', 110, 30, 't&e-hod', 'tyeh2014', 1);
    $mail = new PHPMailer();
    //Luego tenemos que iniciar la validación por SMTP:
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->Host = "envasadoras.com.mx";
    // SMTP a utilizar. Por ej. smtp.elserver.com
    //$mail->Username = "******"; // Correo completo a utilizar
    //$mail->Password = "******"; // Contraseña
    $mail->Port = 25;
    // Puerto a utilizar
    $mail->From = "t&e-hod@envasadoras.com.mx";
    // Desde donde enviamos (Para mostrar)
    $mail->FromName = "Sistema de Gastos de Viaje";
    $cnt = 0;
    if (stristr($_mto, ",") === FALSE) {
        //EVALUAMOS SI TIENE , PARA SACAR A LOS USUARIOS QUE SE MANDARA EL MAIL :)
        $mail->AddAddress($_mto, $_mname);
    } else {
        $aux = explode(",", $_mto);
        foreach ($aux as $direccion) {
            $mail->AddAddress(trim($direccion), $_mname);
            $cnt++;
        }
    }
    $mail->WordWrap = 50;
    // set word wrap
    $mail->IsHTML(TRUE);
    // send as HTML
    $mail->Subject = $_msubject;
    $mail->Body = $_mbody;
    if (!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
        return -1;
    }
    return 0;
    //echo "    Mensaje Enviado.\n";
}
示例#4
0
 public function action_index()
 {
     if (!empty($_REQUEST["f_rename"])) {
         if ($this->model->valid($_POST["f_mail"], $_POST["f_login"]) > 0) {
             $maincfg = Configs::readCfg("main", tbuild);
             if ($maincfg["usemd5"] == 0) {
                 $pwd = $this->model->viewPwd($_POST["f_login"]);
             } else {
                 $pwd = $this->model->getNewPwd($_POST["f_login"], 1);
             }
             if ($this->configs["useMail"] != 1) {
                 echo "<script>alert('password is: {$pwd}');</script>";
             } else {
                 $c_mail = Configs::readCfg("mail", tbuild);
                 require "libraries/PHPMailer/PHPMailerAutoload.php";
                 $pop = new POP3();
                 $pop->Authorise($c_mail["mailhost"], $c_mail["mailport"], $c_mail["mailtmout"], $c_mail["mailboxf"], $c_mail["mailpbf"], $c_mail["maildlvl"]);
                 $mail = new PHPMailer();
                 $mail->CharSet = "UTF-8";
                 $mail->Host = $c_mail["mailhost"];
                 $mail->SMTPAuth = true;
                 $mail->Username = $c_mail["mailboxf"];
                 $mail->Password = $c_mail["mailpbf"];
                 $mail->SetFrom($c_mail["mailboxf"], $c_mail["mailnamefrom"]);
                 $mail->AddReplyTo($c_mail["mailboxf"], $c_mail["mailnib"]);
                 $mail->Subject = "Register";
                 $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
                 // optional, comment out and test
                 $this->view->set("fl_login", $_POST["f_login"])->set("fl_pwd", $pwd);
                 $mail->MsgHTML($this->view->out("register", "mail", 2));
                 $mail->AddAddress($_POST['f_mail']);
                 if (!$mail->Send()) {
                     $this->model->toLog("Mail error:" . $mail->ErrorInfo, "register", 13);
                 }
                 echo "<script>alert('Password was send to your e-mail');</script>";
             }
         }
     }
     $this->view->out("forgotpwd");
 }
示例#5
0
         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';
     $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");
示例#6
0
 /**
  * Simple static wrapper for all-in-one POP before SMTP
  * @param $host
  * @param bool $port
  * @param bool $tval
  * @param string $username
  * @param string $password
  * @param int $debug_level
  * @return bool
  */
 public static function popBeforeSmtp($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
 {
     $pop = new POP3();
     return $pop->authorise($host, $port, $tval, $username, $password, $debug_level);
 }
示例#7
0
do_action('wp-mail.php');
/** Get the POP3 class with which to access the mailbox. */
require_once ABSPATH . WPINC . '/class-pop3.php';
/** Only check at this interval for new messages. */
if (!defined('WP_MAIL_INTERVAL')) {
    define('WP_MAIL_INTERVAL', 300);
}
// 5 minutes
$last_checked = get_transient('mailserver_last_checked');
if ($last_checked) {
    wp_die(__('Slow down cowboy, no need to check for new mails so often!'));
}
set_transient('mailserver_last_checked', true, WP_MAIL_INTERVAL);
$time_difference = get_option('gmt_offset') * HOUR_IN_SECONDS;
$phone_delim = '::';
$pop3 = new POP3();
if (!$pop3->connect(get_option('mailserver_url'), get_option('mailserver_port')) || !$pop3->user(get_option('mailserver_login'))) {
    wp_die(esc_html($pop3->ERROR));
}
$count = $pop3->pass(get_option('mailserver_pass'));
if (false === $count) {
    wp_die(esc_html($pop3->ERROR));
}
if (0 === $count) {
    $pop3->quit();
    wp_die(__('There doesn&#8217;t seem to be any new mail.'));
}
for ($i = 1; $i <= $count; $i++) {
    $message = $pop3->get($i);
    $bodysignal = false;
    $boundary = '';
function wp_mail_receive()
{
    global $xoopsDB, $wpdb, $wp_id, $siteurl, $blog_charset, $wp_pop3;
    require_once ABSPATH . WPINC . '/class-pop3.php';
    timer_start();
    $use_cache = 1;
    $time_difference = get_settings('time_difference');
    // Get Server Time Zone
    // If Server Time Zone is not collect, Please comment out following line;
    $server_timezone = date("O");
    // echo "Server TimeZone is ".date('O')."<br />";
    // If Server Time Zone is not collect, Please uncomment following line and set collect timezone value;
    // $server_timezone = "+0900"; //This is a sample value for JST+0900
    $server_timezone = $server_timezone / 100;
    $weblog_timezone = $server_timezone + $time_difference;
    error_reporting(2037);
    $wp_pop3 = new POP3();
    if (!$wp_pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {
        echo "Ooops {$wp_pop3->ERROR} <br />\n";
        return;
    }
    $Count = $wp_pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
    if ($Count == false) {
        if (!$wp_pop3->FP) {
            echo "Oooops Login Failed: {$wp_pop3->ERROR}<br />\n";
        } else {
            echo "No Message<br />\n";
            $wp_pop3->quit();
        }
        return;
    }
    // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
    register_shutdown_function('wp_mail_quit');
    for ($iCount = 1; $iCount <= $Count; $iCount++) {
        $MsgOne = $wp_pop3->get($iCount);
        if (!$MsgOne || gettype($MsgOne) != 'array') {
            echo "oops, {$wp_pop3->ERROR}<br />\n";
            $wp_pop3->quit();
            return;
        }
        $content = '';
        $content_type = '';
        $boundary = '';
        $att_boundary = '';
        $hatt_boundary = '';
        $bodysignal = 0;
        $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
        while (list($lineNum, $line) = each($MsgOne)) {
            if (strlen($line) < 3) {
                $bodysignal = 1;
            }
            if ($bodysignal) {
                $content .= $line;
            } else {
                if (preg_match('/^Content-Type:\\s+(.*?)\\;/i', $line, $match)) {
                    $content_type = $match[1];
                    $content_type = strtolower($match[1]);
                }
                if ($content_type == 'multipart/mixed' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $att_boundary == '') {
                    $att_boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/alternative' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $boundary == '') {
                    $boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/related' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $hatt_boundary == '') {
                    $hatt_boundary = trim($match[1]);
                }
                if (preg_match('/Subject: /', $line)) {
                    $subject = trim($line);
                    $subject = substr($subject, 9, strlen($subject) - 9);
                    if (function_exists('mb_decode_mimeheader')) {
                        $subject1 = mb_decode_mimeheader($subject);
                        if ($subject != $subject) {
                            $sub_charset = mb_internal_encoding();
                        } else {
                            $sub_charset = "auto";
                        }
                        $subject = $subject1;
                    }
                    if (get_settings('use_phoneemail')) {
                        $subject = explode(get_settings('phoneemail_separator'), $subject);
                        $subject = trim($subject[0]);
                    }
                }
                if (preg_match('/Date: /', $line)) {
                    // of the form '20 Mar 2002 20:32:37'
                    $ddate = trim($line);
                    $ddate = str_replace('Date: ', '', $ddate);
                    if (strpos($ddate, ',')) {
                        $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
                    }
                    $date_arr = explode(' ', $ddate);
                    $date_time = explode(':', $date_arr[3]);
                    $ddate_H = $date_time[0];
                    $ddate_i = $date_time[1];
                    $ddate_s = $date_time[2];
                    $ddate_m = $date_arr[1];
                    $ddate_d = $date_arr[0];
                    $ddate_Y = $date_arr[2];
                    $mail_timezone = trim(ereg_replace("\\([^)]*\\)", "", $date_arr[4])) / 100;
                    // echo "Email TimeZone is {$date_arr[4]}<br />";
                    $mail_time_difference = $weblog_timezone - $mail_timezone;
                    for ($i = 0; $i < 12; $i++) {
                        if ($ddate_m == $dmonths[$i]) {
                            $ddate_m = $i + 1;
                        }
                    }
                    $ddate_U = mktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
                    $ddate_U = $ddate_U + $mai_time_difference * 3600;
                    $post_date = date('Y-m-d H:i:s', $ddate_U);
                }
            }
        }
        if (!ereg(get_settings('subjectprefix'), $subject)) {
            continue;
        }
        $charset = "";
        $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches);
        if ($ncharset) {
            $charset = $matches[1];
        }
        $ddate_today = time() + $time_difference * 3600;
        $ddate_difference_days = ($ddate_today - $ddate_U) / 86400;
        if ($ddate_difference_days > 14) {
            echo "Too old<br />\n";
            continue;
        }
        if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) {
            $userpassstring = '';
            echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n";
            echo "<p><b>{$iCount}</b></p><p><b>Subject: </b>{$subject}</p>\n";
            $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));
            $attachment = false;
            if ($att_boundary) {
                $contents = explode('--' . $att_boundary, $content);
                $content = $contents[1];
                $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches);
                if ($ncharset) {
                    $charset = $matches[1];
                }
                $content = explode("\r\n\r\n", $content, 2);
                $content = $content[1];
            }
            if ($hatt_boundary) {
                $contents = explode('--' . $hatt_boundary, $content);
                $content = $contents[1];
                if (preg_match('/Content-Type: multipart\\/alternative\\;\\s*boundary\\=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)"/i', $content, $matches)) {
                    $boundary = trim($matches[1]);
                    $content = explode('--' . $boundary, $content);
                    $content = $content[2];
                }
                $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
                if ($ncharset) {
                    $charset = $matches[1];
                }
                $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
                $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
            } else {
                if ($boundary) {
                    $content = explode('--' . $boundary, $content);
                    $content = $content[2];
                    if (preg_match('/Content-Type: multipart\\/related\\;\\s*boundary=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)/i', $content, $matches)) {
                        $hatt_boundary = trim($matches[1]);
                        $contents = explode('--' . $hatt_boundary, $content);
                        $content = $contents[1];
                    }
                    $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
                    if ($ncharset) {
                        $charset = $matches[1];
                    }
                    $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
                    $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
                }
            }
            $content = trim($content);
            echo "<p><b>Content-type:</b> {$content_type}, <b>boundary:</b> {$boundary}</p>\n";
            echo "<p><b>att_boundary:</b> {$att_boundary}, <b>hatt_boundary:</b> {$hatt_boundary}</p>\n";
            echo "<p><b>charset:</b>{$charset}, <b>BLOG charset:</b>{$blog_charset}</p>\n";
            // echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
            if ($charset == "" || trim(strtoupper($charset)) == "ISO-2022-JP") {
                $charset = "JIS";
            }
            if (trim(strtoupper($charset)) == "SHIFT_JIS") {
                $charset = "SJIS";
            }
            $btpos = strpos($content, get_settings('bodyterminator'));
            if ($btpos) {
                $content = substr($content, 0, $btpos);
            }
            $content = trim($content);
            $blah = explode("\n", preg_replace("/^[\n\r\\s]*/", "", strip_tags($content)));
            $firstline = preg_replace("/[\n\r]/", "", $blah[0]);
            $secondline = $blah[1];
            if (get_settings('use_phoneemail')) {
                echo "<p><b>Use Phone Mail:</b> Yes</p>\n";
                $btpos = strpos($firstline, get_settings('phoneemail_separator'));
                if ($btpos) {
                    $userpassstring = trim(substr($firstline, 0, $btpos));
                    $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    $btpos = strpos($content, get_settings('phoneemail_separator'));
                    if ($btpos) {
                        $userpassstring = trim(substr($content, 0, $btpos));
                        $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    }
                }
                $contentfirstline = $blah[1];
            } else {
                echo "<p><b>Use Phone Mail:</b> No</p>\n";
                $userpassstring = strip_tags($firstline);
                $contentfirstline = '';
            }
            $flat = 999.0;
            $flon = 999.0;
            $secondlineParts = explode(':', strip_tags($secondline));
            if (strncmp($secondlineParts[0], "POS", 3) == 0) {
                echo "Found POS:<br>\n";
                // echo "Second parts is:".$secondlineParts[1];
                // the second line is the postion listing line
                $secLineParts = explode(',', $secondlineParts[1]);
                $flatStr = $secLineParts[0];
                $flonStr = $secLineParts[1];
                // echo "String are ".$flatStr.$flonStr;
                $flat = floatval($secLineParts[0]);
                $flon = floatval($secLineParts[1]);
                // echo "values are ".$flat." and ".$flon;
                // ok remove that position... we should not have it in the final output
                $content = str_replace($secondline, '', $content);
            }
            $blah = explode(':', $userpassstring);
            $user_login = $blah[0];
            $user_pass = $blah[1];
            if (function_exists('mb_convert_encoding')) {
                $user_login = mb_convert_encoding(trim($user_login), $blog_charset, $charset);
            } else {
                $user_login = trim($user_login);
            }
            $content = $contentfirstline . str_replace($firstline, '', $content);
            $content = trim($content);
            // Please uncomment following line, only if you want to check user and password.
            // echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";
            echo "<p><b>Login:</b> {$user_login}, <b>Pass:</b> *********</p>";
            if ($xoopsDB) {
                $sql = "SELECT ID, user_level FROM {$wpdb->users[$wp_id]} WHERE user_login='******' ORDER BY ID DESC LIMIT 1";
                $result = $wpdb->get_row($sql);
                if (!$result) {
                    echo "<p><b>Wrong Login.</b></p></div>\n";
                    continue;
                } else {
                    $sql = "SELECT * FROM " . $xoopsDB->prefix('users') . " WHERE uname='{$user_login}' AND pass='******' ORDER BY uid DESC LIMIT 1";
                    $result1 = $wpdb->get_row($sql);
                    if (!$result1) {
                        echo "<p><b>Wrong login or password.</b></p></div>\n";
                        continue;
                    }
                }
            } else {
                $sql = "SELECT ID, user_level FROM {$wpdb->users[$wp_id]} WHERE user_login='******' AND user_pass='******' ORDER BY ID DESC LIMIT 1";
                $result = $wpdb->get_row($sql);
                if (!$result) {
                    echo "<p><b>Wrong login or password.</b></p></div>\n";
                    continue;
                }
            }
            $user_level = $result->user_level;
            $post_author = $result->ID;
            if ($user_level > 0) {
                $post_title = xmlrpc_getposttitle($content);
                if ($post_title == '') {
                    $post_title = $subject;
                }
                $post_category = get_settings('default_category');
                if (preg_match('/<category>(.+?)<\\/category>/is', $content, $matchcat)) {
                    $post_category = xmlrpc_getpostcategory($content);
                }
                if ($post_category == '') {
                    $post_category = get_settings('default_post_category');
                }
                if (function_exists('mb_convert_encoding')) {
                    echo "Subject : " . mb_convert_encoding($subject, $blog_charset, $sub_charset) . " <br />\n";
                } else {
                    echo "Subject : " . $subject . " <br />\n";
                }
                echo "Category : {$post_category} <br />\n";
                if (!get_settings('emailtestonly')) {
                    // Attaching Image Files Save
                    if ($att_boundary != "") {
                        $attachment = wp_getattach($contents[2], trim($user_login), 1);
                    }
                    if ($boundary != "" && $hatt_boundary != "") {
                        for ($i = 2; $i < count($contents); $i++) {
                            $hattachment = wp_getattach($contents[$i], trim($user_login), 0);
                            if ($hattachment) {
                                if (preg_match("/Content-Id: \\<([^\\>]*)>/i", $contents[$i], $matches)) {
                                    $content = preg_replace("/(cid:" . preg_quote($matches[1]) . ")/", "{$siteurl}/attach/" . $hattachment, $content);
                                }
                            }
                        }
                    }
                    if ($boundary != "") {
                        $content = preg_replace("/\\=[\r\n]/", "", $content);
                        $content = preg_replace("/[\r\n]/", " ", $content);
                    }
                    $content = preg_replace("|\n([^\n])|", " \$1", $content);
                    $content = preg_replace("/\\=([0-9a-fA-F]{2,2})/e", "pack('c',base_convert('\\1',16,10))", $content);
                    if (function_exists('mb_convert_encoding')) {
                        $content = addslashes(mb_convert_encoding(trim($content), $blog_charset, $charset));
                        $post_title = addslashes(trim(mb_convert_encoding($post_title, $blog_charset, $sub_charset)));
                    } else {
                        $content = addslashes(trim($content));
                        $post_title = addslashes(trim($post_title));
                    }
                    // If we find an attachment, add it to the post
                    if ($attachment) {
                        if (file_exists("attach/thumb-" . $attachment)) {
                            $content = "<a href=\"" . $siteurl . "/attach/" . $attachment . "\"><img style=\"float: left;\" hspace=\"6\" src = \"" . $siteurl . "/attach/thumb-" . $attachment . "\"  alt=\"moblog\" ></a>" . $content . "<br clear=left>";
                        } else {
                            $content = "<a href=\"" . $siteurl . "/attach/" . $attachment . "\"><img style=\"float: left;\" hspace=\"6\" src = \"" . $siteurl . "/attach/" . $attachment . "\"  alt=\"moblog\" ></a>" . $content . "<br clear=left>";
                        }
                    }
                    if ($flat > 500) {
                        $sql = "INSERT INTO {$wpdb->posts[$wp_id]} (post_author, post_date, post_content, post_title, post_category) VALUES ({$post_author}, '{$post_date}', '{$content}', '{$post_title}', {$post_category})";
                    } else {
                        $sql = "INSERT INTO {$wpdb->posts[$wp_id]} (post_author, post_date, post_content, post_title, post_category, post_lat, post_lon) VALUES ({$post_author}, '{$post_date}', '{$content}', '{$post_title}', {$post_category}, {$flat}, {$flon})";
                    }
                    $result = $wpdb->query($sql);
                    $post_ID = $wpdb->insert_id;
                    echo "Post ID = {$post_ID}<br />\n";
                    if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
                        sleep($sleep_after_edit);
                    }
                    $blog_ID = 1;
                    if ($flat < 500) {
                        pingGeoUrl($post_ID);
                    }
                    // Double check it's not there already
                    $exists = $wpdb->get_row("SELECT * FROM {$wpdb->post2cat[$wp_id]} WHERE post_id = {$post_ID} AND category_id = {$post_category}");
                    if (!$exists && $result) {
                        $wpdb->query("\n\t\t\t\t\t\tINSERT INTO {$wpdb->post2cat[$wp_id]}\n\t\t\t\t\t\t(post_id, category_id)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$post_ID}, {$post_category})\n\t\t\t\t\t\t");
                    }
                    pingWeblogs($blog_ID);
                    pingBlogs($blog_ID);
                    //					pingback($content, $post_ID);
                    do_action('publish_post', $post_ID);
                    do_action('publish_phone', $post_ID);
                }
                echo "\n<p><b>Posted title:</b> {$post_title}<br />\n";
                echo "<b>Posted content:</b><br /><pre>" . $content . "</pre></p>\n";
                if (!$wp_pop3->delete($iCount)) {
                    echo "<p>Oops " . $wp_pop3->ERROR . "</p></div>\n";
                    $wp_pop3->reset();
                    return;
                } else {
                    echo "<p>Mission complete, message <strong>{$iCount}</strong> deleted.</p>\n";
                }
            } else {
                echo "<p><strong>Level 0 users can\\'t post.</strong></p>\n";
            }
            echo "</div>\n";
        }
    }
    $wp_pop3->quit();
    timer_stop($output_debugging_info);
    return;
}
 public function configuracaoSMTP()
 {
     $pop = new POP3();
     $pop->authorise("mbox.redeunaviva.rio", 110, 30, "formulario.adesao=redeunaviva.rio", "redeunaviva", 1);
     $mail = new PHPMailer();
     $mail->SetLanguage("br");
     $mail->IsSMTP();
     $mail->IsHTML(true);
     $mail->SMTPSecure = "tls";
     $mail->SMTPAuth = "true";
     $mail->Host = "smtp.redeunaviva.rio";
     //Seu servidor SMTP
     $mail->Mailer = "smtp";
     //Usando protocolo SMTP
     //        $mail->SMTPDebug = 1;
     $mail->Username = "******";
     $mail->Password = "******";
     $mail->Port = 587;
     $to = '*****@*****.**';
     //seu e-mail
     $mail->From = $to;
     //email do remetente
     $mail->Sender = $to;
     //email do remetente
     $mail->FromName = "RedeUnaViva";
     //Nome de formatado do remetente
     $mail->AddAddress($to);
     //O destino do email
     $mail->AddBCC($this->email);
     //Envio com cópia oculta
     $mail->Subject = "RedeUnaViva - Formulário de Adesão - Web ";
     // . $this->titulo; //Assunto do email
     $mail->CharSet = "UTF-8";
 }
示例#10
0
function cforms_phpmailer($no, $frommail, $field_email, $to, $vsubject, $message, $formdata, $htmlmessage, $htmlformdata, $file = 'ac')
{
    global $smtpsettings, $phpmailer, $cformsSettings;
    $eol = $cformsSettings['global']['cforms_crlf'][b] != 1 ? "\r\n" : "\n";
    if (file_exists(dirname(__FILE__) . '/class.phpmailer.php') && !class_exists('PHPMailer')) {
        require_once dirname(__FILE__) . '/class.phpmailer.php';
        require_once dirname(__FILE__) . '/class.smtp.php';
        if ($smtpsettings[6] == '1') {
            require_once dirname(__FILE__) . '/class.pop3.php';
        }
    }
    ### pop before smtp?
    if ($smtpsettings[6] == '1' && class_exists('POP3')) {
        $debuglevel = 0;
        $pop = new POP3();
        $pop->Authorise($smtpsettings[7], $smtpsettings[8], 30, $smtpsettings[9], $smtpsettings[10], $debuglevel);
    }
    $mail = new PHPMailer();
    $mail->ClearAllRecipients();
    $mail->ClearAddresses();
    $mail->ClearAttachments();
    $mail->CharSet = 'utf-8';
    $mail->SetLanguage('en', dirname(__FILE__) . '/');
    $mail->PluginDir = dirname(__FILE__) . '/';
    $mail->IsSMTP();
    $mail->Host = $smtpsettings[1];
    if ((int) $cformsSettings['form' . $no]['cforms' . $no . '_emailpriority'] > 0) {
        $mail->Priority = (int) $cformsSettings['form' . $no]['cforms' . $no . '_emailpriority'];
    }
    ### $mail->SMTPDebug = true;
    if ($smtpsettings[4] != '') {
        $mail->SMTPSecure = $smtpsettings[4];
        ### sets the prefix to the servier
        $mail->Port = $smtpsettings[5];
        ### set the SMTP port
    }
    if ($smtpsettings[2] != '') {
        $mail->SMTPAuth = true;
        ### turn on SMTP authentication
        $mail->Username = $smtpsettings[2];
        ### SMTP username
        $mail->Password = $smtpsettings[3];
        ### SMTP password
    }
    $temp2 = array();
    ###from
    if (preg_match('/([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $frommail, $temp)) {
        $mail->From = $temp[0];
    }
    if (preg_match('/(.*)\\s+(([\\w-\\.]+@|<)).*/', $frommail, $temp2)) {
        $mail->FromName = str_replace('"', '', $temp2[1]);
    } else {
        $mail->FromName = $temp[0];
    }
    $temp2 = array();
    ### reply-to
    if (preg_match('/([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $field_email, $temp)) {
        if (preg_match('/(.*)\\s+(([\\w-\\.]+@|<)).*/', $field_email, $temp2)) {
            $mail->AddReplyTo($temp[0], str_replace('"', '', $temp2[1]));
        } else {
            $mail->AddReplyTo($temp[0]);
        }
    }
    ### TAF: add CC
    if (substr($cformsSettings['form' . $no]['cforms' . $no . '_tellafriend'], 0, 1) == '1' && $file == 'ac') {
        $mail->AddCC($temp[0], str_replace('"', '', $temp2[1]));
    }
    ### bcc
    $te = array();
    $t = array();
    $addresses = explode(',', stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_bcc']));
    foreach ($addresses as $a) {
        if (preg_match('/([\\w-+\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $a, $te)) {
            $mail->AddBCC($te[0]);
        }
    }
    ###to
    ###if( preg_match('/[\w-\.]+@([\w-]+\.)+[\w-]{2,4}/',$to,$temp) )
    ###	$mail->AddAddress($temp[0]);
    $addresses = explode(',', $to);
    foreach ($addresses as $address) {
        if (preg_match('/([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $address, $temp)) {
            if (preg_match('/(.*)\\s+(([\\w-\\.]+@|<)).*/', $address, $temp2)) {
                $mail->AddAddress($temp[0], str_replace('"', '', $temp2[1]));
            } else {
                $mail->AddAddress($temp[0]);
            }
        }
    }
    ###
    ### HTML email ?
    ###
    if ($htmlmessage != '') {
        $htmlmessage = str_replace('=3D', '=', $htmlmessage);
        ###remove 3D's
        $htmlformdata = str_replace('=3D', '=', $htmlformdata);
        ###remove 3D's,
        $mail->IsHTML(true);
        $mail->Body = "<html>" . $eol . "<body>" . stripslashes($htmlmessage) . (substr($cformsSettings['form' . $no]['cforms' . $no . '_formdata'], 1, 1) == '1' && $htmlformdata != '' ? $eol . $htmlformdata : '') . $eol . "</body></html>" . $eol;
        $mail->AltBody = stripslashes($message) . (substr($cformsSettings['form' . $no]['cforms' . $no . '_formdata'], 0, 1) == '1' && $formdata != '' ? $eol . $formdata : '');
    } else {
        $mail->Body = stripslashes($message) . (substr($cformsSettings['form' . $no]['cforms' . $no . '_formdata'], 0, 1) == '1' && $formdata != '' ? $eol . $formdata : '');
    }
    ###
    ### adding attachments
    ###
    global $fdata;
    if ($file == '1' && !$cformsSettings['form' . $no]['cforms' . $no . '_noattachments']) {
        foreach ($fdata as $file) {
            if ($file[name] != '') {
                $n = substr($file[name], strrpos($file[name], $cformsSettings['global']['cforms_IIS']) + 1, strlen($file[name]));
                $m = getMIME(strtolower(substr($n, strrpos($n, '.') + 1, strlen($n))));
                $mail->AddAttachment($file[name], $n, 'base64', $m);
                ### optional name
            }
        }
        ### for
    }
    ### end adding attachments
    $mail->Subject = $vsubject;
    $sentadmin = $mail->Send();
    if ($sentadmin) {
        return 1;
    } else {
        return $mail->ErrorInfo;
    }
}
require_once ABSPATH . WPINC . '/class-pop3.php';
timer_start();
$use_cache = 1;
$output_debugging_info = 0;
# =1 if you want to output debugging info
$time_difference = get_settings('time_difference');
//echo "Server TimeZone is ".date('O')."<br />";
//Get Server Time Zone
// If Server Time Zone is not collect, Please comment out following line;
$server_timezone = date("O");
// If Server Time Zone is not collect, Please uncomment following line and set collect timezone value;
// $server_timezone = "+0900"; //This is a sample value for JST+0900
$server_timezone = $server_timezone / 100;
$weblog_timezone = $server_timezone + $time_difference;
error_reporting(2037);
$pop3 = new POP3();
if (!$pop3->connect($mailserver_url, $mailserver_port)) {
    echo "Ooops {$pop3->ERROR} <br />\n";
    exit;
}
$Count = $pop3->login($mailserver_login, $mailserver_pass);
if (!$Count || $Count == -1) {
    echo "<h1>Login Failed: {$pop3->ERROR}</h1>\n";
    $pop3->quit();
    exit;
}
// ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
//register_shutdown_function($pop3->quit());
for ($iCount = 1; $iCount <= $Count; $iCount++) {
    $MsgOne = $pop3->get($iCount);
    if (!$MsgOne || gettype($MsgOne) != 'array') {
示例#12
0
文件: setup.php 项目: jprice/EHCP
function mail_fetch_login()
{
    require_once SM_PATH . 'include/validate.php';
    include_once SM_PATH . 'functions/imap.php';
    require_once SM_PATH . 'plugins/mail_fetch/class.POP3.php';
    require_once SM_PATH . 'plugins/mail_fetch/functions.php';
    global $data_dir, $imapServerAddress, $imapPort;
    sqgetGlobalVar('username', $username, SQ_SESSION);
    sqgetGlobalVar('key', $key, SQ_COOKIE);
    $mailfetch_newlog = getPref($data_dir, $username, 'mailfetch_newlog');
    $outMsg = '';
    $mailfetch_server_number = getPref($data_dir, $username, 'mailfetch_server_number');
    if (!isset($mailfetch_server_number)) {
        $mailfetch_server_number = 0;
    }
    $mailfetch_cypher = getPref($data_dir, $username, 'mailfetch_cypher');
    if ($mailfetch_server_number < 1) {
        $mailfetch_server_number = 0;
    }
    for ($i_loop = 0; $i_loop < $mailfetch_server_number; $i_loop++) {
        $mailfetch_login_[$i_loop] = getPref($data_dir, $username, "mailfetch_login_{$i_loop}");
        $mailfetch_fref_[$i_loop] = getPref($data_dir, $username, "mailfetch_fref_{$i_loop}");
        $mailfetch_pass_[$i_loop] = getPref($data_dir, $username, "mailfetch_pass_{$i_loop}");
        if ($mailfetch_cypher == 'on') {
            $mailfetch_pass_[$i_loop] = decrypt($mailfetch_pass_[$i_loop]);
        }
        if ($mailfetch_pass_[$i_loop] != '' && ($mailfetch_login_[$i_loop] == 'on' && $mailfetch_newlog == 'on' || $mailfetch_fref_[$i_loop] == 'on')) {
            $mailfetch_server_[$i_loop] = getPref($data_dir, $username, "mailfetch_server_{$i_loop}");
            $mailfetch_port_[$i_loop] = getPref($data_dir, $username, "mailfetch_port_{$i_loop}");
            $mailfetch_alias_[$i_loop] = getPref($data_dir, $username, "mailfetch_alias_{$i_loop}");
            $mailfetch_user_[$i_loop] = getPref($data_dir, $username, "mailfetch_user_{$i_loop}");
            $mailfetch_lmos_[$i_loop] = getPref($data_dir, $username, "mailfetch_lmos_{$i_loop}");
            $mailfetch_uidl_[$i_loop] = getPref($data_dir, $username, "mailfetch_uidl_{$i_loop}");
            $mailfetch_subfolder_[$i_loop] = getPref($data_dir, $username, "mailfetch_subfolder_{$i_loop}");
            $mailfetch_server = $mailfetch_server_[$i_loop];
            $mailfetch_port = $mailfetch_port_[$i_loop];
            $mailfetch_user = $mailfetch_user_[$i_loop];
            $mailfetch_alias = $mailfetch_alias_[$i_loop];
            $mailfetch_pass = $mailfetch_pass_[$i_loop];
            $mailfetch_lmos = $mailfetch_lmos_[$i_loop];
            $mailfetch_login = $mailfetch_login_[$i_loop];
            $mailfetch_uidl = $mailfetch_uidl_[$i_loop];
            $mailfetch_subfolder = $mailfetch_subfolder_[$i_loop];
            // $outMsg .= "$mailfetch_alias checked<br>";
            // $outMsg .= "$mailfetch_alias_[$i_loop]<br>";
            $pop3 = new POP3($mailfetch_server, 60);
            if (!$pop3->connect($mailfetch_server, $mailfetch_port)) {
                $outMsg .= _("Warning, ") . $pop3->ERROR;
                continue;
            }
            $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10);
            $Count = $pop3->login($mailfetch_user, $mailfetch_pass);
            if (($Count == false || $Count == -1) && $pop3->ERROR != '') {
                $outMsg .= _("Login Failed:") . $pop3->ERROR;
                continue;
            }
            //   register_shutdown_function($pop3->quit());
            $msglist = $pop3->uidl();
            $i = 1;
            for ($j = 1; $j < sizeof($msglist); $j++) {
                if ($msglist["{$j}"] == $mailfetch_uidl) {
                    $i = $j + 1;
                    break;
                }
            }
            if ($Count < $i) {
                $pop3->quit();
                continue;
            }
            if ($Count == 0) {
                $pop3->quit();
                continue;
            } else {
                $newmsgcount = $Count - $i + 1;
            }
            // Faster to get them all at once
            $mailfetch_uidl = $pop3->uidl();
            if (!is_array($mailfetch_uidl) && $mailfetch_lmos == 'on') {
                $outMsg .= _("Server does not support UIDL.");
            }
            for (; $i <= $Count; $i++) {
                if (!ini_get('safe_mode')) {
                    set_time_limit(20);
                }
                // 20 seconds per message max
                $Message = "";
                $MessArray = $pop3->get($i);
                if (!$MessArray or gettype($MessArray) != "array") {
                    $outMsg .= _("Warning, ") . $pop3->ERROR;
                    continue 2;
                }
                while (list($lineNum, $line) = each($MessArray)) {
                    $Message .= $line;
                }
                /**
                 * check if mail folder is not null and subscribed
                 * Function can check if mail folder is only unsubscribed 
                 * and use unsubscribed mail folder.
                 */
                if ($mailfetch_subfolder == '' || !mail_fetch_check_folder($imap_stream, $mailfetch_subfolder)) {
                    fputs($imap_stream, "A3{$i} APPEND INBOX {" . strlen($Message) . "}\r\n");
                } else {
                    fputs($imap_stream, "A3{$i} APPEND {$mailfetch_subfolder} {" . strlen($Message) . "}\r\n");
                }
                $Line = fgets($imap_stream, 1024);
                if (substr($Line, 0, 1) == '+') {
                    fputs($imap_stream, $Message);
                    fputs($imap_stream, "\r\n");
                    sqimap_read_data($imap_stream, "A3{$i}", false, $response, $message);
                    if ($mailfetch_lmos != 'on') {
                        $pop3->delete($i);
                    }
                } else {
                    echo "{$Line}";
                    $outMsg .= _("Error Appending Message!");
                }
            }
            $pop3->quit();
            sqimap_logout($imap_stream);
            if (is_array($mailfetch_uidl)) {
                setPref($data_dir, $username, "mailfetch_uidl_{$i_loop}", array_pop($mailfetch_uidl));
            }
        }
    }
    if (trim($outMsg) != '') {
        echo '<br><font size="1">' . _("Mail Fetch Result:") . "<br>{$outMsg}</font>";
    }
    if ($mailfetch_newlog == 'on') {
        setPref($data_dir, $username, 'mailfetch_newlog', 'off');
    }
}
示例#13
0
 public function checkBounced()
 {
     if ($this->config->get('ne_bounce') && $this->config->get('ne_bounce_email') && $this->config->get('ne_bounce_pop3_server') && $this->config->get('ne_bounce_pop3_user') && $this->config->get('ne_bounce_pop3_password')) {
         require_once DIR_SYSTEM . 'library/pop3_ne.php';
         $pop3 = new POP3();
         if (!@$pop3->connect($this->config->get('ne_bounce_pop3_server'), $this->config->get('ne_bounce_pop3_port') ? $this->config->get('ne_bounce_pop3_port') : 110) || !$pop3->user($this->config->get('ne_bounce_pop3_user'))) {
             return false;
         }
         $count = @$pop3->pass($this->config->get('ne_bounce_pop3_password'));
         if (false === $count) {
             return false;
         }
         if (0 === $count) {
             $pop3->quit();
             return false;
         }
         for ($i = 1; $i <= $count; $i++) {
             $message = $pop3->get($i);
             foreach ($message as $line) {
                 if (preg_match('/X-NEMail: /i', $line)) {
                     $hash = trim(str_replace('X-NEMail: ', '', $line));
                 }
             }
             if (isset($hash) && $hash) {
                 $hash = base64_decode(urldecode($hash));
                 $test = explode('|', $hash);
                 if (count($test) == 2) {
                     $data = array('uid' => $test[1], 'email' => $test[0]);
                     $query = $this->db->query("UPDATE `" . DB_PREFIX . "ne_stats_personal` SET bounced = '1' WHERE stats_personal_id = '" . (int) $data['uid'] . "' AND email = '" . $this->db->escape($data['email']) . "'");
                     if ($query) {
                         $pop3->delete($i);
                     } else {
                         $pop3->reset();
                     }
                 }
             } else {
                 if ($this->config->get('ne_bounce_delete')) {
                     $pop3->delete($i);
                 }
             }
         }
         $pop3->quit();
     }
 }
示例#14
0
// php errors
define('DISPLAY_XPM4_ERRORS', true);
// display XPM4 errors
// path to 'POP3.php' and 'SMTP.php' files from XPM4 package
require_once '../POP3.php';
require_once '../SMTP.php';
$f = '*****@*****.**';
// from mail address / account username
$t = '*****@*****.**';
// to mail address
$p = 'password';
// account password
// standard mail message RFC2822
$m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: test' . "\r\n" . 'Content-Type: text/plain' . "\r\n\r\n" . 'Text message.';
// connect to 'pop3.hostname.net' POP3 server address with authentication username '$f' and password '$p'
$p = POP3::Connect('pop3.hostname.net', $f, $p) or die(print_r($_RESULT));
// connect to 'smtp.hostname.net' SMTP server address
$c = SMTP::Connect('smtp.hostname.net') or die(print_r($_RESULT));
// send mail
$s = SMTP::Send($c, array($t), $m, $f);
// print result
if ($s) {
    echo 'Sent !';
} else {
    print_r($_RESULT);
}
// disconnect from SMTP server
SMTP::Disconnect($c);
// disconnect from POP3 server
POP3::Disconnect($p);
示例#15
0
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 
}
<html>
<head>
<title>POP before SMTP Test</title>
</head>

<body>

<pre>
<?php 
require 'class.phpmailer.php';
require 'class.pop3.php';
$pop = new POP3();
$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->IsHTML(false);
$mail->Host = 'relay.example.com';
$mail->From = '*****@*****.**';
$mail->FromName = 'Example Mailer';
$mail->Subject = 'My subject';
$mail->Body = 'Hello world';
$mail->AddAddress('*****@*****.**', 'First Last');
if (!$mail->Send()) {
    echo $mail->ErrorInfo;
}
?>
</pre>

</body>
</html>
示例#17
0
 /**
  * @param UserModel  $user
  * @param EmailModel $emailModel
  * @param array      $variables
  *
  * @throws Exception
  * @return bool
  */
 private function _sendEmail(UserModel $user, EmailModel $emailModel, $variables = array())
 {
     // Get the saved email settings.
     $emailSettings = $this->getSettings();
     if (!isset($emailSettings['protocol'])) {
         throw new Exception(Craft::t('Could not determine how to send the email.  Check your email settings.'));
     }
     // Fire an 'onBeforeSendEmail' event
     $event = new Event($this, array('user' => $user, 'emailModel' => $emailModel, 'variables' => $variables));
     $this->onBeforeSendEmail($event);
     // Is the event giving us the go-ahead?
     if ($event->performAction) {
         // In case a plugin changed any variables in onBeforeSendEmail
         $variables = $event->params['variables'];
         $email = new \PHPMailer(true);
         // Default the charset to UTF-8
         $email->CharSet = 'UTF-8';
         // Add a reply to (if any).  Make sure it’s set before setting From, because email is dumb.
         if (!empty($emailModel->replyTo)) {
             $email->addReplyTo($emailModel->replyTo);
         }
         // Set the "from" information.
         $email->setFrom($emailModel->fromEmail, $emailModel->fromName);
         // Check which protocol we need to use.
         switch ($emailSettings['protocol']) {
             case EmailerType::Gmail:
             case EmailerType::Smtp:
                 $this->_setSmtpSettings($email, $emailSettings);
                 break;
             case EmailerType::Pop:
                 $pop = new \POP3();
                 if (!isset($emailSettings['host']) || !isset($emailSettings['port']) || !isset($emailSettings['username']) || !isset($emailSettings['password']) || StringHelper::isNullOrEmpty($emailSettings['host']) || StringHelper::isNullOrEmpty($emailSettings['port']) || StringHelper::isNullOrEmpty($emailSettings['username']) || StringHelper::isNullOrEmpty($emailSettings['password'])) {
                     throw new Exception(Craft::t('Host, port, username and password must be configured under your email settings.'));
                 }
                 if (!isset($emailSettings['timeout'])) {
                     $emailSettings['timeout'] = $this->_defaultEmailTimeout;
                 }
                 $pop->authorize($emailSettings['host'], $emailSettings['port'], $emailSettings['timeout'], $emailSettings['username'], $emailSettings['password'], craft()->config->get('devMode') ? 1 : 0);
                 $this->_setSmtpSettings($email, $emailSettings);
                 break;
             case EmailerType::Sendmail:
                 $email->isSendmail();
                 break;
             case EmailerType::Php:
                 $email->isMail();
                 break;
             default:
                 $email->isMail();
         }
         if (!$this->_processTestToEmail($email, 'Address')) {
             $email->addAddress($user->email, $user->getFullName());
         }
         // Add any custom headers
         if (!empty($emailModel->customHeaders)) {
             foreach ($emailModel->customHeaders as $headerName => $headerValue) {
                 $email->addCustomHeader($headerName, $headerValue);
             }
         }
         // Add any BCC's
         if (!empty($emailModel->bcc)) {
             if (!$this->_processTestToEmail($email, 'BCC')) {
                 foreach ($emailModel->bcc as $bcc) {
                     if (!empty($bcc['email'])) {
                         $bccEmail = $bcc['email'];
                         $bccName = !empty($bcc['name']) ? $bcc['name'] : '';
                         $email->addBCC($bccEmail, $bccName);
                     }
                 }
             }
         }
         // Add any CC's
         if (!empty($emailModel->cc)) {
             if (!$this->_processTestToEmail($email, 'CC')) {
                 foreach ($emailModel->cc as $cc) {
                     if (!empty($cc['email'])) {
                         $ccEmail = $cc['email'];
                         $ccName = !empty($cc['name']) ? $cc['name'] : '';
                         $email->addCC($ccEmail, $ccName);
                     }
                 }
             }
         }
         // Add a sender header (if any)
         if (!empty($emailModel->sender)) {
             $email->Sender = $emailModel->sender;
         }
         // Add any string attachments
         if (!empty($emailModel->stringAttachments)) {
             foreach ($emailModel->stringAttachments as $stringAttachment) {
                 $email->addStringAttachment($stringAttachment['string'], $stringAttachment['fileName'], $stringAttachment['encoding'], $stringAttachment['type']);
             }
         }
         // Add any normal disc attachments
         if (!empty($emailModel->attachments)) {
             foreach ($emailModel->attachments as $attachment) {
                 $email->addAttachment($attachment['path'], $attachment['name'], $attachment['encoding'], $attachment['type']);
             }
         }
         $variables['user'] = $user;
         $oldLanguage = craft()->getLanguage();
         // If they have a preferredLocale, use that.
         if ($user->preferredLocale) {
             craft()->setLanguage($user->preferredLocale);
         }
         $email->Subject = craft()->templates->renderString($emailModel->subject, $variables, true);
         // If they populated an htmlBody, use it.
         if ($emailModel->htmlBody) {
             $renderedHtmlBody = craft()->templates->renderString($emailModel->htmlBody, $variables, true);
             $email->msgHTML($renderedHtmlBody);
             $email->AltBody = craft()->templates->renderString($emailModel->body, $variables, true);
         } else {
             // They didn't provide an htmlBody, so markdown the body.
             $renderedHtmlBody = craft()->templates->renderString(StringHelper::parseMarkdown($emailModel->body), $variables, true);
             $email->msgHTML($renderedHtmlBody);
             $email->AltBody = craft()->templates->renderString($emailModel->body, $variables, true);
         }
         craft()->setLanguage($oldLanguage);
         if (!$email->Send()) {
             // Fire an 'onSendEmailError' event
             $this->onSendEmailError(new Event($this, array('user' => $user, 'emailModel' => $emailModel, 'variables' => $variables, 'error' => $email->ErrorInfo)));
             throw new Exception(Craft::t('Email error: {error}', array('error' => $email->ErrorInfo)));
         }
         Craft::log('Successfully sent email with subject: ' . $email->Subject, LogLevel::Info);
         // Fire an 'onSendEmail' event
         $this->onSendEmail(new Event($this, array('user' => $user, 'emailModel' => $emailModel, 'variables' => $variables)));
         return true;
     }
     return false;
 }
示例#18
0
function osc_sendMail($params)
{
    if (key_exists('add_bcc', $params)) {
        if (!is_array($params['add_bcc']) && $params['add_bcc'] != '') {
            $params['add_bcc'] = array($params['add_bcc']);
        }
    }
    require_once osc_lib_path() . 'phpmailer/class.phpmailer.php';
    if (osc_mailserver_pop()) {
        require_once osc_lib_path() . 'phpmailer/class.pop3.php';
        $pop = new POP3();
        $pop->Authorise(isset($params['host']) ? $params['host'] : osc_mailserver_host(), isset($params['port']) ? $params['port'] : osc_mailserver_port(), 30, isset($params['username']) ? $params['username'] : osc_mailserver_username(), isset($params['username']) ? $params['username'] : osc_mailserver_username(), 0);
    }
    $mail = new PHPMailer(true);
    try {
        $mail->CharSet = 'utf-8';
        if (osc_mailserver_auth()) {
            $mail->IsSMTP();
            $mail->SMTPAuth = true;
        } else {
            if (osc_mailserver_pop()) {
                $mail->IsSMTP();
            }
        }
        $mail->SMTPSecure = isset($params['ssl']) ? $params['ssl'] : osc_mailserver_ssl();
        $mail->Username = isset($params['username']) ? $params['username'] : osc_mailserver_username();
        $mail->Password = isset($params['password']) ? $params['password'] : osc_mailserver_password();
        $mail->Host = isset($params['host']) ? $params['host'] : osc_mailserver_host();
        $mail->Port = isset($params['port']) ? $params['port'] : osc_mailserver_port();
        $mail->From = isset($params['from']) ? $params['from'] : osc_contact_email();
        $mail->FromName = isset($params['from_name']) ? $params['from_name'] : osc_page_title();
        $mail->Subject = isset($params['subject']) ? $params['subject'] : '';
        $mail->Body = isset($params['body']) ? $params['body'] : '';
        $mail->AltBody = isset($params['alt_body']) ? $params['alt_body'] : '';
        $to = isset($params['to']) ? $params['to'] : '';
        $to_name = isset($params['to_name']) ? $params['to_name'] : '';
        if (key_exists('add_bcc', $params)) {
            foreach ($params['add_bcc'] as $bcc) {
                $mail->AddBCC($bcc);
            }
        }
        if (isset($params['reply_to'])) {
            $mail->AddReplyTo($params['reply_to']);
        }
        if (isset($params['attachment'])) {
            $mail->AddAttachment($params['attachment']);
        }
        $mail->IsHTML(true);
        $mail->AddAddress($to, $to_name);
        $mail->Send();
        return true;
    } catch (phpmailerException $e) {
        error_log("phpmailerException in osc_sendMail() Error: " . $mail->ErrorInfo, 0);
        return false;
    } catch (Exception $e) {
        error_log("Exception in osc_sendMail() Error" . $mail->ErrorInfo, 0);
        return false;
    }
    return false;
}
示例#19
0
文件: getmail.php 项目: LFSF/oras
            echo $strmessage;
            if ($color) {
                echo "</font>";
            }
        }
    }
}
//---------------------------------------
switch ($Settings->get('eblog_method')) {
    case 'pop3':
        //--------------------------------------------------------------------
        // eblog_method = POP3 (original)
        //--------------------------------------------------------------------
        // error_reporting( E_ALL );
        load_class('_ext/_pop3.class.php');
        $pop3 = new POP3();
        $port = $Settings->get('eblog_server_port') ? $Settings->get('eblog_server_port') : '110';
        echo T_('Connecting to pop server...'), "<br />\n";
        if (!$pop3->connect($Settings->get('eblog_server_host'), $port)) {
            echo T_('Connection failed: ') . $pop3->ERROR . " <br />\n";
            exit;
        }
        echo T_('Logging into pop server...'), "<br />\n";
        $Count = $pop3->login($Settings->get('eblog_username'), $Settings->get('eblog_password'));
        if (!$Count || $Count == -1) {
            echo T_('No mail or Login Failed:'), " {$pop3->ERROR} <br />\n";
            $pop3->quit();
            exit;
        }
        if ($test_type == 1) {
            echo '<br /><br />' . T_('All Tests complete');
<?php

/**
 * This example shows how to use POP-before-SMTP for authentication.
 */
require '../PHPMailerAutoload.php';
//Authenticate via POP3.
//After this you should be allowed to submit messages over SMTP for a while.
//Only applies if your host supports POP-before-SMTP.
$pop = POP3::popBeforeSmtp('pop3.example.com', 110, 30, 'username', 'password', 1);
//Create a new PHPMailer instance
//Passing true to the constructor enables the use of exceptions for error handling
$mail = new PHPMailer(true);
try {
    $mail->isSMTP();
    //Enable SMTP debugging
    // 0 = off (for production use)
    // 1 = client messages
    // 2 = client and server messages
    $mail->SMTPDebug = 2;
    //Ask for HTML-friendly debug output
    $mail->Debugoutput = 'html';
    //Set the hostname of the mail server
    $mail->Host = "mail.example.com";
    //Set the SMTP port number - likely to be 25, 465 or 587
    $mail->Port = 25;
    //Whether to use SMTP authentication
    $mail->SMTPAuth = false;
    //Set who the message is to be sent from
    $mail->setFrom('*****@*****.**', 'First Last');
    //Set an alternative reply-to address
示例#21
0
文件: mail.php 项目: notzen/e107
 /**
  * Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed
  * 
  * @var array $overrides - array of values which override mail-related prefs. Key is the same as the corresponding pref.
  * @return none
  */
 public function __construct($overrides = FALSE)
 {
     parent::__construct(FALSE);
     // Parent constructor - no exceptions for now
     $e107 = e107::getInstance();
     global $pref;
     //Load up Email Templates
     include e107::coreTemplatePath('email', 'front');
     $this->templateOption['email'] = array('header' => $EMAIL_HEADER, 'footer' => $EMAIL_FOOTER);
     $this->templateOption['notify'] = array('header' => $NOTIFY_HEADER, 'footer' => $NOTIFY_FOOTER);
     $this->templateOption['mailout'] = array('header' => $MAILOUT_HEADER, 'footer' => $MAILOUT_FOOTER);
     $this->CharSet = 'utf-8';
     $this->SetLanguage(CORE_LC);
     if ($overrides === FALSE || !is_array($overrides)) {
         $overrides = array();
     }
     foreach (array('mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin', 'smtp_pop3auth') as $k) {
         if (!isset($overrides[$k])) {
             $overrides[$k] = $pref[$k];
         }
     }
     $this->pause_amount = varset($pref['mail_pause'], 10);
     $this->pause_time = varset($pref['mail_pausetime'], 1);
     if (varsettrue($pref['mail_options'])) {
         $this->general_opts = explode(',', $pref['mail_options'], '');
     }
     if (defined('MAIL_DEBUG')) {
         echo 'Mail_options: ' . $pref['mail_options'] . ' Count: ' . count($this->general_opts) . '<br />';
     }
     foreach ($this->general_opts as $k => $v) {
         $v = trim($v);
         $this->general_opts[$k] = $v;
         if (strpos($v, 'hostname') === 0) {
             list(, $this->HostName) = explode('=', $v);
             if (defined('MAIL_DEBUG')) {
                 echo "Host name set to: {$this->HostName}<br />";
             }
         }
     }
     list($this->logEnable, $this->add_email) = explode(',', varset($pref['mail_log_options'], '0,0'));
     switch ($overrides['mailer']) {
         case 'smtp':
             $smtp_options = array();
             $temp_opts = explode(',', varset($pref['smtp_options'], ''));
             if (varsettrue($overrides['smtp_pop3auth'])) {
                 $temp_opts[] = 'pop3auth';
             }
             // Legacy option - remove later
             if (varsettrue($pref['smtp_keepalive'])) {
                 $temp_opts[] = 'keepalive';
             }
             // Legacy option - remove later
             foreach ($temp_opts as $k => $v) {
                 if (strpos($v, '=') !== FALSE) {
                     list($v, $k) = explode('=', $v, 2);
                     $smtp_options[trim($v)] = trim($k);
                 } else {
                     $smtp_options[trim($v)] = TRUE;
                     // Simple on/off option
                 }
             }
             unset($temp_opts);
             $this->IsSMTP();
             // Enable SMTP functions
             if (varsettrue($smtp_options['helo'])) {
                 $this->Helo = $smtp_options['helo'];
             }
             if (isset($smtp_options['pop3auth'])) {
                 // Need POP-before-SMTP authorisation
                 require_once e_HANDLER . 'phpmailer/class.pop3.php';
                 $pop = new POP3();
                 $pop->Authorise($overrides['smtp_server'], 110, 30, $overrides['smtp_username'], $overrides['smtp_password'], 1);
             }
             $this->Mailer = 'smtp';
             $this->localUseVerp = isset($smtp_options['useVERP']);
             if (isset($smtp_options['secure'])) {
                 switch ($smtp_options['secure']) {
                     case 'TLS':
                         $this->SMTPSecure = 'tls';
                         $this->Port = 465;
                         // Can also use port 587, and maybe even 25
                         break;
                     case 'SSL':
                         $this->SMTPSecure = 'ssl';
                         $this->Port = 465;
                         break;
                     default:
                         if (defined('MAIL_DEBUG')) {
                             echo "Invalid option: {$smtp_options['secure']}<br />";
                         }
                 }
             }
             $this->SMTPKeepAlive = varset($smtp_options['keepalive'], FALSE);
             // ***** Control this
             $this->Host = $overrides['smtp_server'];
             if ($overrides['smtp_username'] && $overrides['smtp_password']) {
                 $this->SMTPAuth = !isset($smtp_options['pop3auth']);
                 $this->Username = $overrides['smtp_username'];
                 $this->Password = $overrides['smtp_password'];
             }
             break;
         case 'sendmail':
             $this->Mailer = 'sendmail';
             $this->Sendmail = $overrides['sendmail'] ? $overrides['sendmail'] : '/usr/sbin/sendmail -t -i -r ' . varsettrue($pref['replyto_email'], $overrides['siteadminemail']);
             break;
         case 'php':
             $this->Mailer = 'mail';
             break;
     }
     if (varsettrue($pref['mail_bounce_email'])) {
         $this->Sender = $pref['mail_bounce_email'];
     }
     $this->FromName = $e107->tp->toHTML(varsettrue($pref['replyto_name'], $overrides['siteadmin']), '', 'RAWTEXT');
     $this->From = $e107->tp->toHTML(varsettrue($pref['replyto_email'], $overrides['siteadminemail']), '', 'RAWTEXT');
     $this->WordWrap = 76;
     // Set a sensible default
     // Now look for any overrides - slightly cumbersome way of doing it, but does give control over what can be set from here
     // Options are those accepted by the arraySet() method.
     foreach (array('SMTPDebug', 'subject', 'from', 'fromname', 'replyto', 'send_html', 'add_html_header', 'attachments', 'cc', 'bcc', 'bouncepath', 'returnreceipt', 'priority', 'extra_header', 'wordwrap', 'split') as $opt) {
         if (isset($overrides[$opt])) {
             $this->arraySet(array($opt => $overrides[$opt]));
         }
     }
 }
function wp_mail_receive()
{
    global $wpdb, $wp_pop3, $img_target;
    require_once ABSPATH . WPINC . '/class-pop3.php';
    timer_start();
    $use_cache = 1;
    $time_difference = get_settings('time_difference');
    $blog_charset = get_settings('blog_charset');
    error_reporting(2037);
    $wp_pop3 = new POP3();
    if (!$wp_pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {
        echo "Ooops {$wp_pop3->ERROR} <br />\n";
        return;
    }
    $mail_count = $wp_pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
    if ($mail_count == false) {
        if (!$wp_pop3->FP) {
            echo "Oooops Login Failed: {$wp_pop3->ERROR}<br />\n";
        } else {
            echo "No Message<br />\n";
            $wp_pop3->quit();
        }
        return;
    }
    // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
    register_shutdown_function('wp_mail_quit');
    for ($mail_num = 1; $mail_num <= $mail_count; $mail_num++) {
        $MsgOne = $wp_pop3->get($mail_num);
        if (!$MsgOne || gettype($MsgOne) != 'array') {
            echo "oops, {$wp_pop3->ERROR}<br />\n";
            $wp_pop3->quit();
            return;
        }
        $content = '';
        $content_type = '';
        $boundary = '';
        $att_boundary = '';
        $hatt_boundary = '';
        $bodysignal = 0;
        $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
        while (list($lineNum, $line) = each($MsgOne)) {
            if (strlen($line) < 3) {
                $bodysignal = 1;
            }
            if ($bodysignal) {
                $content .= $line;
            } else {
                if (preg_match('/^Content-Type:\\s+(.*?)\\;/i', $line, $match)) {
                    $content_type = $match[1];
                    $content_type = strtolower($match[1]);
                }
                if ($content_type == 'multipart/mixed' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $att_boundary == '') {
                    $att_boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/alternative' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $boundary == '') {
                    $boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/related' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $hatt_boundary == '') {
                    $hatt_boundary = trim($match[1]);
                }
                if (preg_match('/Subject: /', $line)) {
                    $subject = trim($line);
                    $subject = substr($subject, 9, strlen($subject) - 9);
                    if (function_exists('mb_decode_mimeheader')) {
                        $subject1 = mb_decode_mimeheader($subject);
                        if ($subject != $subject) {
                            $sub_charset = mb_internal_encoding();
                        } else {
                            $sub_charset = "auto";
                        }
                        $subject = $subject1;
                    }
                    if (get_settings('use_phoneemail')) {
                        $subject = explode(get_settings('phoneemail_separator'), $subject);
                        $subject = trim($subject[0]);
                    }
                }
                if (preg_match('/Date: /', $line)) {
                    // of the form '20 Mar 2002 20:32:37'
                    $ddate = trim($line);
                    $ddate = str_replace('Date: ', '', $ddate);
                    if (strpos($ddate, ',')) {
                        $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
                    }
                    $ddate_U = strtotime($ddate) + $time_difference * 3600;
                    $post_date = date('Y-m-d H:i:s', $ddate_U);
                }
            }
        }
        if (!ereg(get_settings('subjectprefix'), $subject)) {
            continue;
        }
        $charset = "";
        $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches);
        if ($ncharset) {
            $charset = $matches[1];
        }
        $ddate_today = time() + $time_difference * 3600;
        $ddate_difference_days = ($ddate_today - $ddate_U) / 86400;
        if ($ddate_difference_days > 14) {
            echo "Too old<br />\n";
            continue;
        }
        if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) {
            $userpassstring = '';
            echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n";
            echo "<p><b>{$mail_num}</b></p><p><b>Subject: </b>{$subject}</p>\n";
            $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));
            $attachment = false;
            if ($att_boundary) {
                $contents = explode('--' . $att_boundary, $content);
                $content = $contents[1];
                $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches);
                if ($ncharset) {
                    $charset = $matches[1];
                }
                $content = explode("\r\n\r\n", $content, 2);
                $content = $content[1];
            }
            if ($hatt_boundary) {
                $contents = explode('--' . $hatt_boundary, $content);
                $content = $contents[1];
                if (preg_match('/Content-Type: multipart\\/alternative\\;\\s*boundary\\=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)"/i', $content, $matches)) {
                    $boundary = trim($matches[1]);
                    $content = explode('--' . $boundary, $content);
                    $content = $content[2];
                }
                $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
                if ($ncharset) {
                    $charset = $matches[1];
                }
                $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
                $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
            } else {
                if ($boundary) {
                    $content = explode('--' . $boundary, $content);
                    $content = $content[2];
                    if (preg_match('/Content-Type: multipart\\/related\\;\\s*boundary=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)/i', $content, $matches)) {
                        $hatt_boundary = trim($matches[1]);
                        $contents = explode('--' . $hatt_boundary, $content);
                        $content = $contents[1];
                    }
                    $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
                    if ($ncharset) {
                        $charset = $matches[1];
                    }
                    $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
                    $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
                }
            }
            $content = trim($content);
            echo "<p><b>Content-type:</b> {$content_type}, <b>boundary:</b> {$boundary}</p>\n";
            echo "<p><b>att_boundary:</b> {$att_boundary}, <b>hatt_boundary:</b> {$hatt_boundary}</p>\n";
            echo "<p><b>charset:</b>{$charset}, <b>BLOG charset:</b>{$blog_charset}</p>\n";
            // echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
            if ($charset == "" || trim(strtoupper($charset)) == "ISO-2022-JP") {
                $charset = "JIS";
            }
            if (trim(strtoupper($charset)) == "SHIFT_JIS") {
                $charset = "SJIS";
            }
            $btpos = strpos($content, get_settings('bodyterminator'));
            if ($btpos) {
                $content = substr($content, 0, $btpos);
            }
            $content = trim($content);
            $blah = explode("\n", preg_replace("/^[\n\r\\s]*/", "", strip_tags($content)));
            $firstline = preg_replace("/[\n\r]/", "", $blah[0]);
            $secondline = $blah[1];
            if (get_settings('use_phoneemail')) {
                echo "<p><b>Use Phone Mail:</b> Yes</p>\n";
                $btpos = strpos($firstline, get_settings('phoneemail_separator'));
                if ($btpos) {
                    $userpassstring = trim(substr($firstline, 0, $btpos));
                    $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    $btpos = strpos($content, get_settings('phoneemail_separator'));
                    if ($btpos) {
                        $userpassstring = trim(substr($content, 0, $btpos));
                        $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    }
                }
                $contentfirstline = $blah[1];
            } else {
                echo "<p><b>Use Phone Mail:</b> No</p>\n";
                $userpassstring = strip_tags($firstline);
                $contentfirstline = '';
            }
            $flat = 999.0;
            $flon = 999.0;
            $secondlineParts = explode(':', strip_tags($secondline));
            if (strncmp($secondlineParts[0], "POS", 3) == 0) {
                echo "Found POS:<br />\n";
                // echo "Second parts is:".$secondlineParts[1];
                // the second line is the postion listing line
                $secLineParts = explode(',', $secondlineParts[1]);
                $flatStr = $secLineParts[0];
                $flonStr = $secLineParts[1];
                // echo "String are ".$flatStr.$flonStr;
                $flat = floatval($secLineParts[0]);
                $flon = floatval($secLineParts[1]);
                // echo "values are ".$flat." and ".$flon;
                // ok remove that position... we should not have it in the final output
                $content = str_replace($secondline, '', $content);
            }
            $blah = explode(':', $userpassstring);
            $user_login = $blah[0];
            $user_pass = $blah[1];
            $user_login = mb_conv(trim($user_login), $blog_charset, $charset);
            $content = $contentfirstline . str_replace($firstline, '', $content);
            $content = trim($content);
            // Please uncomment following line, only if you want to check user and password.
            // echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";
            echo "<p><b>Login:</b> {$user_login}, <b>Pass:</b> *********</p>";
            if (!user_pass_ok($user_login, $user_pass)) {
                echo "<p><b>Error: Wrong Login.</b></p></div>\n";
                continue;
            }
            $userdata = get_userdatabylogin($user_login);
            $user_level = $userdata->user_level;
            $post_author = $userdata->ID;
            if ($user_level > 0) {
                $post_title = xmlrpc_getposttitle($content);
                if ($post_title == '') {
                    $post_title = $subject;
                }
                echo "Subject : " . mb_conv($post_title, $blog_charset, $sub_charset) . " <br />\n";
                $post_category = get_settings('default_category');
                if (preg_match('/<category>(.+?)<\\/category>/is', $content, $matchcat)) {
                    $post_category = xmlrpc_getpostcategory($content);
                }
                if (empty($post_category)) {
                    $post_category = get_settings('default_post_category');
                }
                echo "Category : {$post_category} <br />\n";
                $post_category = explode(',', $post_category);
                if (!get_settings('emailtestonly')) {
                    // Attaching Image Files Save
                    if ($att_boundary != "") {
                        $attachment = wp_getattach($contents[2], "user-" . trim($post_author), 1);
                    }
                    if ($boundary != "" && $hatt_boundary != "") {
                        for ($i = 2; $i < count($contents); $i++) {
                            $hattachment = wp_getattach($contents[$i], "user-" . trim($post_author), 0);
                            if ($hattachment) {
                                if (preg_match("/Content-Id: \\<([^\\>]*)>/i", $contents[$i], $matches)) {
                                    $content = preg_replace("/(cid:" . preg_quote($matches[1]) . ")/", get_settings('fileupload_url') . '/' . $hattachment, $content);
                                }
                            }
                        }
                    }
                    if ($boundary != "") {
                        $content = preg_replace("/\\=[\r\n]/", "", $content);
                        $content = preg_replace("/[\r\n]/", " ", $content);
                    }
                    $content = preg_replace("|\n([^\n])|", " \$1", $content);
                    $content = preg_replace("/\\=([0-9a-fA-F]{2,2})/e", "pack('c',base_convert('\\1',16,10))", $content);
                    $content = mb_conv(trim($content), $blog_charset, $charset);
                    // If we find an attachment, add it to the post
                    if ($attachment) {
                        if (isset($img_target) && $img_target) {
                            $img_target = ' target="' . $img_target . '"';
                        } else {
                            $img_target = '';
                        }
                        if (file_exists(get_settings('fileupload_realpath') . "/thumb-" . $attachment)) {
                            $content = "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src = \"" . get_settings('fileupload_url') . '/thumb-' . rawurlencode($attachment) . "\" alt=\"" . $attachment . "\" title=\"" . $attachment . "\" /></a>" . $content . "<br clear=\"left\" />";
                        } else {
                            $content = "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src = \"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\" alt=\"" . $attachment . "\" title=\"" . $attachment . "\" /></a>" . $content . "<br clear=\"left\" />";
                        }
                    }
                    $postHandler =& wp_handler('Post');
                    $postObject =& $postHandler->create();
                    $postObject->setVar('post_content', $content);
                    $postObject->setVar('post_title', trim(mb_conv($post_title, $blog_charset, $sub_charset)));
                    $postObject->setVar('post_date', $post_date);
                    $postObject->setVar('post_author', $post_author);
                    $postObject->setVar('post_category', $post_category[0]);
                    $postObject->setVar('post_name', sanitize_title($post_title));
                    if ($flat < 500) {
                        $postObject->setVar('post_lat', $flat);
                        $postObject->setVar('post_lon', $flon);
                    }
                    if (!$postHandler->insert($postObject, true)) {
                        echo "<b>Error: Insert New Post</b><br />";
                    }
                    $post_ID = $postObject->getVar('ID');
                    echo "Post ID = {$post_ID}<br />\n";
                    $postObject->assignCategories($post_category);
                    do_action('publish_post', $post_ID);
                    do_action('publish_phone', $post_ID);
                    if ($flat < 500) {
                        pingGeoUrl($post_ID);
                    }
                    $blog_ID = 1;
                    pingWeblogs($blog_ID);
                    pingBlogs($blog_ID);
                    pingback($content, $post_ID);
                }
                echo "\n<p><b>Posted title:</b> {$post_title}<br />\n";
                echo "<b>Posted content:</b><br /><pre>" . $content . "</pre></p>\n";
                if (!$wp_pop3->delete($mail_num)) {
                    echo "<p>Oops " . $wp_pop3->ERROR . "</p></div>\n";
                    $wp_pop3->reset();
                    return;
                } else {
                    echo "<p>Mission complete, message <strong>{$mail_num}</strong> deleted.</p>\n";
                }
            } else {
                echo "<p><strong>Level 0 users can\\'t post.</strong></p>\n";
            }
            echo "</div>\n";
        }
    }
    $wp_pop3->quit();
    timer_stop($output_debugging_info);
    return;
}
示例#23
0
$count = 0;
if ($action == "list") {
    OpenTable();
    echo "<center><b>" . _MD_WEBMAIL_MAILBOXESFOR . " {$username}</b></center>";
    echo "<br /><table border=\"1\" align=\"center\" width=\"80%\">" . "<tr class='bg2'><td bgcolor=\"{$bgcolor2}\" width=\"33%\">&nbsp;<b>" . _MD_WEBMAIL_ACCOUNT . "</b></td><td bgcolor=\"{$bgcolor2}\" width=\"33%\" align=\"center\">&nbsp;<b>" . _MD_WEBMAIL_EMAILS . "</b></td><td bgcolor=\"{$bgcolor2}\" width=\"33%\" align=\"center\">&nbsp;<b>" . _MD_WEBMAIL_TOTALSIZE . "</b></td></tr>";
    while ($row = $xoopsDB->fetchArray($result)) {
        $count++;
        $server = $row[popserver];
        $port = $row[port];
        $apop = $row[apop];
        $username = $row[uname];
        $rc4 = new rc4crypt();
        $password = $rc4->endecrypt($username, $row[passwd], "de");
        $account = $row[account];
        $serverid = $row[id];
        $pop3 = new POP3($server, $username, $password, $port, $apop);
        if ($pop3->Open()) {
            $stats = $pop3->Stats();
            $mailsum = $stats["message"];
            $mailmem = round($stats["size"] / 1024) . " Kbytes";
            $pop3->Close();
        } else {
            $mailsum = "Not Connectable!";
            $mailmem = "N/A";
        }
        echo "<tr>" . "<td align=\"left\">&nbsp;" . "<a href='inbox.php?id={$serverid}'>{$account}</a></td>" . "<td align=\"center\">{$mailsum}</td>" . "<td align=\"center\">{$mailmem}</td></tr>";
    }
    echo "</table><br /><br />" . "<center>" . _MD_WEBMAIL_SELECTACCOUNT . "</center>";
    CloseTable();
}
echo "<div align='right'>" . $xoopsModule->name() . " Var. " . $webmail_var . "<br />" . $webmail_credits . "</div>";
 /**
  * Use a fake POP3 server to test POP-before-SMTP auth
  * With a known-bad login
  */
 public function testPopBeforeSmtpBad()
 {
     //Start a fake POP server on a different port
     //so we don't inadvertently connect to the previous instance
     $pid = shell_exec('nohup ./runfakepopserver.sh 1101 >/dev/null 2>/dev/null & printf "%u" $!');
     $this->pids[] = $pid;
     sleep(2);
     //Test a known-bad login
     $this->assertFalse(POP3::popBeforeSmtp('localhost', 1101, 10, 'user', 'xxx', $this->Mail->SMTPDebug), 'POP before SMTP should have failed');
     shell_exec('kill -TERM ' . escapeshellarg($pid));
     sleep(2);
 }
示例#25
0
    $i_stop = $i_start + 1;
}
for ($i_loop = $i_start; $i_loop < $i_stop; $i_loop++) {
    $mailfetch_server = $mailfetch_server_[$i_loop];
    $mailfetch_port = $mailfetch_port_[$i_loop];
    $mailfetch_user = $mailfetch_user_[$i_loop];
    if ($mailfetch_pass_[$i_loop] == '') {
        sqgetGlobalVar("pass_{$i_loop}", $mailfetch_pass, SQ_POST);
    } else {
        $mailfetch_pass = $mailfetch_pass_[$i_loop];
    }
    $mailfetch_lmos = $mailfetch_lmos_[$i_loop];
    $mailfetch_login = $mailfetch_login_[$i_loop];
    $mailfetch_uidl = $mailfetch_uidl_[$i_loop];
    $mailfetch_subfolder = $mailfetch_subfolder_[$i_loop];
    $pop3 = new POP3($mailfetch_server, 60);
    echo '<br>' . html_tag('table', html_tag('tr', html_tag('td', '<b>' . _("Fetching from ") . htmlspecialchars($mailfetch_alias_[$i_loop] == '' ? $mailfetch_server : $mailfetch_alias_[$i_loop]) . '</b>', 'center'), '', $color[9]), '', '', 'width="90%"');
    flush();
    if (!$pop3->connect($mailfetch_server, $mailfetch_port)) {
        Mail_Fetch_Status(_("Oops, ") . $pop3->ERROR);
        continue;
    }
    Mail_Fetch_Status(_("Opening IMAP server"));
    $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10);
    // check if destination folder is not set, is not subscribed and is not \noselect folder
    if ($mailfetch_subfolder == '' || !mail_fetch_check_folder($imap_stream, $mailfetch_subfolder)) {
        $mailfetch_subfolder = 'INBOX';
    }
    Mail_Fetch_Status(_("Opening POP server"));
    $Count = $pop3->login($mailfetch_user, $mailfetch_pass);
    if (($Count == false || $Count == -1) && $pop3->ERROR != '') {
示例#26
0
$db["addr"] = "localhost";
$db["user"] = "";
$db["pass"] = "";
$db["link"] = FALSE;
$db["use"] = "mail";
// optional
$db["dir_table"] = "inbox";
// Table for header data
$db["msg_table"] = "messages";
// Table for complete Messages (/w header)...
// Your own free Vars
// Save to MySQL ??
$savetomysql = TRUE;
$savetofile = TRUE;
$delete = FALSE;
$pop3 = new POP3($log, $log_file, $apop_detect);
if ($pop3->connect($server)) {
    if ($pop3->login($username, $password)) {
        if (!($msg_list = $pop3->get_office_status())) {
            echo $pop3->error;
            return;
        }
    } else {
        echo $pop3->error;
        return;
    }
} else {
    echo $pop3->error;
    return;
}
$db["link"] = mysql_connect($db["addr"], $db["user"], $db["pass"]) or die(mysql_error());
<?php

require dirname(__FILE__) . '/wp-config.php';
require_once ABSPATH . WPINC . '/class-pop3.php';
error_reporting(2037);
$time_difference = get_settings('gmt_offset') * 3600;
$phone_delim = '::';
$pop3 = new POP3();
if (!$pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {
    echo "Ooops {$pop3->ERROR} <br />\n";
    exit;
}
$count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
if (0 == $count) {
    die(__('There doesn&#8217;t seem to be any new mail.'));
}
for ($i = 1; $i <= $count; $i++) {
    $message = $pop3->get($i);
    $content = '';
    $content_type = '';
    $boundary = '';
    $bodysignal = 0;
    $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
    foreach ($message as $line) {
        if (strlen($line) < 3) {
            $bodysignal = 1;
        }
        if ($bodysignal) {
            $content .= $line;
        } else {
            if (preg_match('/Content-Type: /i', $line)) {
<html>
<head>
<title>POP before SMTP Test</title>
</head>
<body>

<?php 
require_once '../class.phpmailer.php';
require_once '../class.pop3.php';
// required for POP before SMTP
$pop = new POP3();
$pop->Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1);
$mail = new PHPMailer(true);
// the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP();
try {
    $mail->SMTPDebug = 2;
    $mail->Host = 'pop3.yourdomain.com';
    $mail->AddReplyTo('*****@*****.**', 'First Last');
    $mail->AddAddress('*****@*****.**', 'John Doe');
    $mail->SetFrom('*****@*****.**', 'First Last');
    $mail->AddReplyTo('*****@*****.**', 'First Last');
    $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
    // optional - MsgHTML will create an alternate automatically
    $mail->MsgHTML(file_GET_contents('contents.html'));
    $mail->AddAttachment('images/phpmailer.gif');
    // attachment
    $mail->AddAttachment('images/phpmailer_mini.gif');
    // attachment
    $mail->Send();
示例#29
0
 function POP3()
 {
     require_once INCLUDE_DIR . 'class.pop3.php';
     POP3::fetchMail();
     //Fetch mail..frequency is limited by POP3 account setting.
 }
示例#30
-2
/**
 * Retrieves email via POP3
 */
function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0)
{
    require_once ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php';
    $emails = array();
    $pop3 = new POP3();
    if (defined('POSTIE_DEBUG')) {
        $pop3->DEBUG = POSTIE_DEBUG;
    }
    DebugEcho("Connecting to {$server}:{$port} ({$protocol})");
    if ($pop3->connect(trim($server), $port)) {
        $msg_count = $pop3->login($email, $password);
        if ($msg_count === false) {
            $msg_count = 0;
        }
    } else {
        if (strpos($pop3->ERROR, "POP3: premature NOOP OK, NOT an RFC 1939 Compliant server") === false) {
            EchoInfo("Mail Connection Time Out. Common Reasons: Server Down, Network Issue, Port/Protocol MisMatch");
        }
        EchoInfo("The Server said: {$pop3->ERROR}");
        $msg_count = 0;
    }
    DebugEcho("message count: {$msg_count}");
    // loop through messages
    //$msgs = $pop3->pop_list();
    //DebugEcho("POP3MessageFetch: messages");
    //DebugDump($msgs);
    for ($i = 1; $i <= $msg_count; $i++) {
        $m = $pop3->get($i);
        if ($m !== false) {
            if (is_array($m)) {
                $emails[$i] = implode('', $m);
                if ($deleteMessages) {
                    if (!$pop3->delete($i)) {
                        EchoInfo('POP3MessageFetch: cannot delete message $i ' . $pop3->ERROR);
                        $pop3->reset();
                        exit;
                    }
                }
            } else {
                DebugEcho("POP3MessageFetch: message {$i} not an array");
            }
        } else {
            EchoInfo("POP3MessageFetch: message {$i} {$pop3->ERROR}");
        }
        if ($maxemails != 0 && $i >= $maxemails) {
            DebugEcho("Max emails ({$maxemails})");
            break;
        }
    }
    //clean up
    $pop3->quit();
    return $emails;
}