예제 #1
0
/**
 * @param $pop
 * @param $user
 * @param $pass
 * @return bool
 */
function account_ok($pop, $user, $pass)
{
    include_once 'lib/webmail/net_pop3.php';
    $pop3 = new Net_POP3();
    $pop3->connect($pop);
    $pop3->login($user, $pass);
    if (!$pop3) {
        $pop3->disconnect();
        return false;
    } else {
        $pop3->disconnect();
        return true;
    }
}
예제 #2
0
function account_ok($pop, $user, $pass)
{
    //include_once ("lib/webmail/pop3.php");
    include_once "lib/webmail/net_pop3.php";
    //$pop3 = new POP3($pop, $user, $pass);
    //$pop3->Open();
    //$err = $pop3->has_error;
    //$pop3->close();
    $pop3 = new Net_POP3();
    $pop3->connect($pop);
    $pop3->login($user, $pass);
    if (!$pop3) {
        $pop3->disconnect();
        return false;
    } else {
        $pop3->disconnect();
        return true;
    }
}
예제 #3
0
 function pop_bounce($host, $port = 995, $login, $password, $list_ID)
 {
     $pop3 = new Net_POP3();
     if (!$pop3->connect('ssl://' . $host, $port)) {
         die('could not log in');
     }
     $pop3->login($login, $password);
     $size = $pop3->numMsg();
     if ($size >= 1) {
         $x = 1;
         while ($x <= $size) {
             #parse the email for bounce information (return message_ID and bounce level)
             #set the bounce status and level of the  message
             set_bounce_status($message_ID);
             $pop3->deleteMsg($x);
             $x++;
         }
     }
     $pop3->disconnect();
 }
예제 #4
0
 function process_inbound_mail($forumId, $suppressErrors = false)
 {
     // require_once ("lib/webmail/pop3.php");
     require_once "lib/webmail/net_pop3.php";
     require_once "lib/mail/mimelib.php";
     //require_once ("lib/webmail/mimeDecode.php");
     include_once "lib/webmail/htmlMimeMail.php";
     $info = $this->get_forum($forumId);
     // for any reason my sybase test machine adds a space to
     // the inbound_pop_server field in the table.
     $info["inbound_pop_server"] = trim($info["inbound_pop_server"]);
     if (!$info["inbound_pop_server"] || empty($info["inbound_pop_server"])) {
         return;
     }
     $pop3 = new Net_POP3();
     $pop3->connect($info["inbound_pop_server"]);
     $pop3->login($info["inbound_pop_user"], $info["inbound_pop_password"]);
     if (!$pop3) {
         return;
     }
     $mailSum = $pop3->numMsg();
     //we don't want the operation to time out... this would result in the same messages being imported over and over...
     //(messages are only removed from the pop server on a gracefull connection termination... ie .not php or webserver a timeout)
     //$maximport should be in a admin config screen, but I don't know how to do that yet.
     $maxImport = 10;
     if ($mailSum > $maxImport) {
         $mailSum = $maxImport;
     }
     for ($i = 1; $i <= $mailSum; $i++) {
         //echo 'loop ' . $i;
         $aux = $pop3->getParsedHeaders($i);
         // If the connection is done, or the mail has an error, or whatever,
         // we try to delete the current mail (because something is wrong with it)
         // and continue on. --rlpowell
         if ($aux == FALSE) {
             $pop3->deleteMsg($i);
             continue;
         }
         //echo '<pre>';
         //print_r ($aux);
         //echo '</pre>';
         if (!isset($aux['From'])) {
             if (isset($aux['Return-path'])) {
                 $aux['From'] = $aux['Return-path'];
             } else {
                 $aux['From'] = "";
                 $aux['Return-path'] = "";
             }
         }
         //try to get the date from the email:
         $postDate = strtotime($aux['Date']);
         if ($postDate == false) {
             $postDate = $this->now;
         }
         //save the original email address, if we don't get a user match, then we
         //can at least give some info about the poster.
         $original_email = $aux["From"];
         //fix mailman addresses, or there is no chance to get a match
         $aux["From"] = str_replace(' at ', '@', $original_email);
         preg_match('/<?([-!#$%&\'*+\\.\\/0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.[-!#$%&\'*+\\.\\/0-9=?A-Z^_`a-z{|}~]+)>?/', $aux["From"], $mail);
         // should we throw out emails w/ invalid (possibly obfusicated) email addressses?
         //this should be an admin option, but I don't know how to put it there yet.
         $throwOutInvalidEmails = false;
         if (!array_key_exists(1, $mail)) {
             if ($throwOutInvalidEmails) {
                 continue;
             }
         }
         $email = $mail[1];
         $full = $pop3->getMsg($i);
         $message = $pop3->getBody($i);
         $output = mime::decode($full);
         //unset ($parts);
         //$this->parse_output($output, $parts, 0);
         if (isset($output["text"][0])) {
             $body = $output["text"][0];
         } elseif (isset($output['parts'][0]["text"][0])) {
             $body = $output['parts'][0]["text"][0];
         } elseif (isset($output['body'])) {
             $body = $output['body'];
         } elseif (isset($output['parts'][0]['html'][0])) {
             // some html message does not have a text part
             $body = $this->htmldecode(strip_tags(preg_replace('/\\n\\r/', '', $output['parts'][0]['html'][0])));
         } elseif (isset($output['parts'][0]['parts'][0]['text'][0])) {
             $body = $output['parts'][0]['parts'][0]['text'][0];
         } else {
             $body = "";
         }
         // Remove 're:' and [forum]. -rlpowell
         $title = trim(preg_replace("/[rR][eE]:/", "", preg_replace("/\\[[-A-Za-z _:]*\\]/", "", $output['header']['subject'])));
         //Todo: check permissions
         $message_id = substr($output['header']["message-id"], 1, strlen($output['header']["message-id"]) - 2);
         if (isset($output['header']["in-reply-to"])) {
             $in_reply_to = substr($output['header']["in-reply-to"], 1, strlen($output['header']["in-reply-to"]) - 2);
         } else {
             $in_reply_to = '';
         }
         // Determine user from email
         $userName = $this->table('users_users')->fetchOne('login', array('email' => $email));
         //use anonomus name feature if we don't have a real name
         if (!$userName) {
             $anonName = $original_email;
         }
         // Determine if the thread already exists.
         $parentId = $this->table('tiki_comments')->fetchOne('threadId', array('object' => $forumId, 'objectType' => 'forum', 'parentId' => 0, 'title' => $title));
         if (!$parentId) {
             /*		
             						This doesn't make any sense to me... why would we say an inbound email is a'thread to discuss a page'?
             						I've updated this to just make a new thread w/ the original email info by seting $parentId = 0
             
             				// No thread already; create it.
             
             				$temp_msid = '';
             
             				$parentId = $this->post_new_comment(
             				'forum:' . $forumId, 0,
             				$userName, $title, 
             				sprintf(tra("Use this thread to discuss the %s page."), "[tiki-index.php?page=$title|$title]"),
             				$temp_msid, $in_reply_to
             				);
             
             				$this->register_forum_post($forumId,0);
             
             				// First post is in reply to this one
             				$in_reply_to = $temp_msid;
             */
             $parentId = 0;
         }
         // post
         $threadid = $this->post_new_comment('forum:' . $forumId, $parentId, $userName, $title, $body, $message_id, $in_reply_to, 'n', '', '', '', $anonName, $postDate);
         $this->register_forum_post($forumId, $parentId);
         // Process attachments
         if (array_key_exists('parts', $output) && count($output['parts']) > 1) {
             $forum_info = $this->get_forum($forumId);
             if ($forum_info['att'] != 'att_no') {
                 $errors = array();
                 foreach ($output['parts'] as $part) {
                     if (array_key_exists('disposition', $part)) {
                         if ($part['disposition'] == 'attachment') {
                             if (strlen($part['d_parameters']['filename']) > 0) {
                                 $part_name = $part['d_parameters']['filename'];
                             } else {
                                 $part_name = "Unnamed File";
                             }
                             $this->add_thread_attachment($forum_info, $threadid, $errors, $part_name, $part['type'], strlen($part['body']), 1, '', $part['body'], $suppressErrors);
                         } elseif ($part['disposition'] == 'inline') {
                             foreach ($part['parts'] as $p) {
                                 $this->add_thread_attachment($forum_info, $threadid, $errors, '-', $p['type'], strlen($p['body']), 1, '', $p['body'], $suppressErrors);
                             }
                         }
                     }
                 }
             }
         }
         // Deal with mail notifications.
         if (array_key_exists('outbound_mails_reply_link', $info) && $info['outbound_mails_for_inbound_mails'] == 'y') {
             //phpinfo();
             include_once 'lib/notifications/notificationemaillib.php';
             sendForumEmailNotification('forum_post_thread', $threadid, $info, $title, $body, $userName, $title, $message_id, $in_reply_to, $threadid, $parentId);
         }
         $pop3->deleteMsg($i);
     }
     $pop3->disconnect();
 }
예제 #5
0
     }
 }
 closedir($h);
 $current = $webmaillib->get_current_webmail_account($user);
 if (!$current) {
     header("location: tiki-webmail.php?locSection=settings");
     die;
 }
 //die(date(time()));
 $smarty->assign('current', $current);
 // Now get messages from mailbox
 //$pop3 = new POP3($current["pop"], $current["username"], $current["pass"]);
 //$pop3->exit = false;    //new
 //$pop3->Open();
 $pop3 = new Net_POP3();
 if (!$pop3->connect($current["pop"]) || !$pop3->login($current["username"], $current["pass"])) {
     echo '<b><br /><center><a href="tiki-webmail.php?locSection=settings">Click here for settings.</a></center></b>';
     die;
 }
 /*
 	if ($pop3->has_error) { //new
 		echo '<b><br /><center><a href="tiki-webmail.php?locSection=settings">Click here for settings.</a></center></b>';
 		die;
 	}
 */
 if (isset($_REQUEST["delete"])) {
     if (isset($_REQUEST["msg"])) {
         check_ticket('webmail');
         // Now we can delete the messages
         foreach (array_keys($_REQUEST["msg"]) as $msg) {
             $listing = $pop3->GetListing($msg);
 function deleteMailsFromServer(MailAccount $account)
 {
     $count = 0;
     if ($account->getDelFromServer() > 0) {
         $max_date = DateTimeValueLib::now();
         $max_date->add('d', -1 * $account->getDelFromServer());
         if ($account->getIsImap()) {
             if ($account->getIncomingSsl()) {
                 $imap = new Net_IMAP($ret, "ssl://" . $account->getServer(), $account->getIncomingSslPort());
             } else {
                 $imap = new Net_IMAP($ret, "tcp://" . $account->getServer());
             }
             if (PEAR::isError($ret)) {
                 Logger::log($ret->getMessage());
                 throw new Exception($ret->getMessage());
             }
             $ret = $imap->login($account->getEmail(), self::ENCRYPT_DECRYPT($account->getPassword()));
             $result = array();
             if ($ret === true) {
                 $mailboxes = MailAccountImapFolders::getMailAccountImapFolders($account->getId());
                 if (is_array($mailboxes)) {
                     foreach ($mailboxes as $box) {
                         if ($box->getCheckFolder()) {
                             $numMessages = $imap->getNumberOfMessages(utf8_decode($box->getFolderName()));
                             for ($i = 1; $i <= $numMessages; $i++) {
                                 $summary = $imap->getSummary($i);
                                 if (is_array($summary)) {
                                     $m_date = DateTimeValueLib::makeFromString($summary[0]['INTERNALDATE']);
                                     if ($m_date instanceof DateTimeValue && $max_date->getTimestamp() > $m_date->getTimestamp()) {
                                         if (MailContents::mailRecordExists($account->getId(), $summary[0]['UID'], $box->getFolderName(), null)) {
                                             $imap->deleteMessages($i);
                                             $count++;
                                         }
                                     } else {
                                         break;
                                     }
                                 }
                             }
                             $imap->expunge();
                         }
                     }
                 }
             }
         } else {
             //require_once "Net/POP3.php";
             $pop3 = new Net_POP3();
             // Connect to mail server
             if ($account->getIncomingSsl()) {
                 $pop3->connect("ssl://" . $account->getServer(), $account->getIncomingSslPort());
             } else {
                 $pop3->connect($account->getServer());
             }
             if (PEAR::isError($ret = $pop3->login($account->getEmail(), self::ENCRYPT_DECRYPT($account->getPassword()), 'USER'))) {
                 throw new Exception($ret->getMessage());
             }
             $emails = $pop3->getListing();
             foreach ($emails as $email) {
                 if (MailContents::mailRecordExists($account->getId(), $email['uidl'], null, null)) {
                     $headers = $pop3->getParsedHeaders($email['msg_id']);
                     $date = DateTimeValueLib::makeFromString(array_var($headers, 'Date'));
                     if ($date instanceof DateTimeValue && $max_date->getTimestamp() > $date->getTimestamp()) {
                         $pop3->deleteMsg($email['msg_id']);
                         $count++;
                     }
                 }
             }
             $pop3->disconnect();
         }
     }
     return $count;
 }
예제 #7
0
 function process_inbound_mail($forumId)
 {
     // require_once ("lib/webmail/pop3.php");
     require_once "lib/webmail/net_pop3.php";
     require_once "lib/mail/mimelib.php";
     //require_once ("lib/webmail/mimeDecode.php");
     include_once "lib/webmail/class.rc4crypt.php";
     include_once "lib/webmail/htmlMimeMail.php";
     $info = $this->get_forum($forumId);
     // for any reason my sybase test machine adds a space to
     // the inbound_pop_server field in the table.
     $info["inbound_pop_server"] = trim($info["inbound_pop_server"]);
     if (!$info["inbound_pop_server"] || empty($info["inbound_pop_server"])) {
         return;
     }
     $pop3 = new Net_POP3();
     $pop3->connect($info["inbound_pop_server"]);
     $pop3->login($info["inbound_pop_user"], $info["inbound_pop_password"]);
     if (!$pop3) {
         return;
     }
     $mailsum = $pop3->numMsg();
     $pop3->disconnect();
     for ($i = 1; $i <= $mailsum; $i++) {
         // Just changed the code to close and re-open the POP3 session for
         // each message; it used to try to retrieve everything in one
         // session.
         //
         // We close and re-open for each message because POP3 won't
         // delete mail until the client quits (so you can back out of
         // accidental deletions in a real user client).  This doesn't apply
         // here, and as it stands if the mailbox gets very full, we end up
         // hitting the mailbox over and over without changing anything,
         // because eventually the session times out.
         //
         // As a side effect, $i doesn't really get used (we're always
         // retrieving the first message).
         //
         // -Robin Powell, 8 Nov 2004
         $pop3->connect($info["inbound_pop_server"]);
         $pop3->login($info["inbound_pop_user"], $info["inbound_pop_password"]);
         $aux = $pop3->getParsedHeaders(1);
         // If the connection is done, or the mail has an error, or whatever,
         // we try to delete the current mail (because something is wrong with it)
         // and continue on. --rlpowell
         if ($aux == FALSE) {
             $pop3->deleteMsg(1);
             continue;
         }
         if (!isset($aux["From"])) {
             $aux['From'] = $aux['Return-path'];
         }
         preg_match('/<?([-!#$%&\'*+\\.\\/0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.[-!#$%&\'*+\\.\\/0-9=?A-Z^_`a-z{|}~]+)>?/', $aux["From"], $mail);
         $email = $mail[1];
         $full = $pop3->getMsg(1);
         $message = $pop3->getBody(1);
         // print( "<pre>" );
         // print_r( $full );
         // print( "</pre>" );
         $output = mime::decode($full);
         //unset ($parts);
         //$this->parse_output($output, $parts, 0);
         // print( "<pre>" );
         // print_r( $output );
         // print( "</pre>" );
         if (isset($output["text"][0])) {
             $body = $output["text"][0];
         } elseif (isset($output['parts'][0]["text"][0])) {
             $body = $output['parts'][0]["text"][0];
         } elseif (isset($output['body'])) {
             $body = $output['body'];
         } else {
             $body = "";
         }
         // print( "<pre>" );
         // print_r( $body );
         // print( "</pre>" );
         // Remove 're:' and [forum]. -rlpowell
         $title = trim(preg_replace("/[rR][eE]:/", "", preg_replace("/\\[[-A-Za-z _:]*\\]/", "", $output['header']['subject'])));
         if (stristr($aux['Subject'], "=?iso-8859-1?") == $aux['Subject']) {
             $title = utf8_encode($title);
         }
         //Todo: check permissions
         $message_id = substr($output['header']["message-id"], 1, strlen($output['header']["message-id"]) - 2);
         if (isset($output['header']["in-reply-to"])) {
             $in_reply_to = substr($output['header']["in-reply-to"], 1, strlen($output['header']["in-reply-to"]) - 2);
         } else {
             $in_reply_to = '';
         }
         // Determine user from email
         $userName = $this->getOne("select `login` from `users_users` where `email`=?", array($email));
         if (!$userName) {
             $user = '';
         }
         // Determine if the thread already exists.
         $parentId = $this->getOne("select `threadId` from `tiki_comments` where\n\t\t    `object`=? and `objectType` = 'forum' and\n\t\t    `parentId`=0 and `title`=?", array($forumId, $title));
         // print( "<pre>parentid:" );
         // print_r( $parentId );
         // print( "</pre>" );
         if (!$parentId) {
             // No thread already; create it.
             $temp_msid = '';
             $parentId = $this->post_new_comment('forum:' . $forumId, 0, $userName, $title, sprintf(tra("Use this thread to discuss the %s page."), "[tiki-index.php?page={$title}|{$title}]"), $temp_msid, $in_reply_to);
             $this->register_forum_post($forumId, 0);
             // First post is in reply to this one
             $in_reply_to = $temp_msid;
         }
         // post
         $threadid = $this->post_new_comment('forum:' . $forumId, $parentId, $userName, $title, $body, $message_id, $in_reply_to);
         $this->register_forum_post($forumId, $parentId);
         // Process attachments
         if (array_key_exists('parts', $output) && count($output['parts']) > 1) {
             foreach ($output['parts'] as $part) {
                 if (array_key_exists('disposition', $part) && $part['disposition'] == "attachment") {
                     if (strlen($part['d_parameters']['filename']) > 0) {
                         $part_name = $part['d_parameters']['filename'];
                     } else {
                         $part_name = "Unnamed File";
                     }
                     $forum_info = $this->get_forum($forumId);
                     $this->add_thread_attachment($forum_info, $threadid, '', $part['body'], $part_name, $part['type'], strlen($part['body']), 1);
                 }
             }
         }
         // Deal with mail notifications.
         if (array_key_exists('outbound_mails_reply_link', $info) && $info['outbound_mails_for_inbound_mails'] == 'y') {
             //phpinfo();
             include_once 'lib/notifications/notificationemaillib.php';
             sendForumEmailNotification('forum_post_thread', $threadid, $info, $title, $body, $userName, $title, $message_id, $in_reply_to, $threadid, $parentId);
         }
         $pop3->deleteMsg(1);
         $pop3->disconnect();
     }
 }
예제 #8
0
 function process_inbound_mail($forumId)
 {
     global $prefs;
     require_once "lib/webmail/net_pop3.php";
     require_once "lib/mail/mimelib.php";
     $info = $this->get_forum($forumId);
     // for any reason my sybase test machine adds a space to
     // the inbound_pop_server field in the table.
     $info["inbound_pop_server"] = trim($info["inbound_pop_server"]);
     if (!$info["inbound_pop_server"] || empty($info["inbound_pop_server"])) {
         return;
     }
     $pop3 = new Net_POP3();
     $pop3->connect($info["inbound_pop_server"]);
     $pop3->login($info["inbound_pop_user"], $info["inbound_pop_password"]);
     if (!$pop3) {
         return;
     }
     $mailSum = $pop3->numMsg();
     //we don't want the operation to time out... this would result in the same messages being imported over and over...
     //(messages are only removed from the pop server on a gracefull connection termination... ie .not php or webserver a timeout)
     //$maximport should be in a admin config screen, but I don't know how to do that yet.
     $maxImport = 10;
     if ($mailSum > $maxImport) {
         $mailSum = $maxImport;
     }
     for ($i = 1; $i <= $mailSum; $i++) {
         //echo 'loop ' . $i;
         $aux = $pop3->getParsedHeaders($i);
         // If the mail came from Tiki, we don't need to add it again
         if (isset($aux['X-Tiki']) && $aux['X-Tiki'] == 'yes') {
             $pop3->deleteMsg($i);
             continue;
         }
         // If the connection is done, or the mail has an error, or whatever,
         // we try to delete the current mail (because something is wrong with it)
         // and continue on. --rlpowell
         if ($aux == FALSE) {
             $pop3->deleteMsg($i);
             continue;
         }
         //echo '<pre>';
         //print_r ($aux);
         //echo '</pre>';
         if (!isset($aux['From'])) {
             if (isset($aux['Return-path'])) {
                 $aux['From'] = $aux['Return-path'];
             } else {
                 $aux['From'] = "";
                 $aux['Return-path'] = "";
             }
         }
         //try to get the date from the email:
         $postDate = strtotime($aux['Date']);
         if ($postDate == false) {
             $postDate = $this->now;
         }
         //save the original email address, if we don't get a user match, then we
         //can at least give some info about the poster.
         $original_email = $aux["From"];
         //fix mailman addresses, or there is no chance to get a match
         $aux["From"] = str_replace(' at ', '@', $original_email);
         preg_match('/<?([-!#$%&\'*+\\.\\/0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.[-!#$%&\'*+\\.\\/0-9=?A-Z^_`a-z{|}~]+)>?/', $aux["From"], $mail);
         // should we throw out emails w/ invalid (possibly obfusicated) email addressses?
         //this should be an admin option, but I don't know how to put it there yet.
         $throwOutInvalidEmails = false;
         if (!array_key_exists(1, $mail)) {
             if ($throwOutInvalidEmails) {
                 continue;
             }
         }
         $email = $mail[1];
         $full = $pop3->getMsg($i);
         $mimelib = new mime();
         $output = $mimelib->decode($full);
         $body = '';
         if ($output['type'] == 'multipart/report') {
             // mimelib doesn't seem to parse error reports properly
             $pop3->deleteMsg($i);
             // and we almost certainly don't want them in the forum
             continue;
             // so do what exactly? log them somewhere? TODO
         }
         require_once 'lib/htmlpurifier_tiki/HTMLPurifier.tiki.php';
         if ($prefs['feature_forum_parse'] === 'y' && $prefs['forum_inbound_mail_parse_html'] === 'y') {
             $body = $mimelib->getPartBody($output, 'html');
             if ($body) {
                 // on some systems HTMLPurifier fails with smart quotes in the html
                 $body = $mimelib->cleanQuotes($body);
                 // some emails have invalid font and span tags that create incorrect purifying of lists
                 $body = preg_replace_callback('/\\<(ul|ol).*\\>(.*)\\<\\/(ul|ol)\\>/Umis', array($this, 'process_inbound_mail_cleanlists'), $body);
                 // Clean the string using HTML Purifier next
                 $body = HTMLPurifier($body);
                 // html emails require some speciaal handling
                 $body = preg_replace('/--(.*)--/', '~np~--$1--~/np~', $body);
                 // disable strikethough syntax
                 $body = preg_replace('/\\{(.*)\\}/', '~np~{$1}~/np~', $body);
                 // disable plugin type things
                 // special handling for MS links which contain underline tags in the label which wiki doesn't like
                 $body = preg_replace('/(\\<a .*\\>)\\<font .*\\>\\<u\\>(.*)\\<\\/u\\>\\<\\/font\\>\\<\\/a\\>/Umis', '$1$2</a>', $body);
                 $body = str_replace("<br /><br />", "<br /><br /><br />", $body);
                 // double linebreaks seem to work better as three?
                 $body = TikiLib::lib('edit')->parseToWiki($body);
                 $body = str_replace("\n\n", "\n", $body);
                 // for some reason emails seem to get line feeds quadrupled
                 $body = preg_replace('/\\[\\[(.*?)\\]\\]/', '[~np~~/np~[$1]]', $body);
                 // links surrounded by [square brackets] need help
             }
         }
         if (!$body) {
             $body = $mimelib->getPartBody($output, 'text');
             if (empty($body)) {
                 // no text part so look for html
                 $body = $mimelib->getPartBody($output, 'html');
                 $body = HTMLPurifier($body);
                 $body = $this->htmldecode(strip_tags($body));
                 $body = str_replace("\n\n", "\n", $body);
                 // and again
                 $body = str_replace("\n\n", "\n", $body);
             }
             if ($prefs['feature_forum_parse'] === 'y') {
                 $body = preg_replace('/--(.*)--/', '~np~--$1--~/np~', $body);
                 // disable strikethough if...
                 $body = preg_replace('/\\{(.*)\\}/', '~np~\\{$1\\}~/np~', $body);
                 // disable plugin type things
             }
             $body = $mimelib->cleanQuotes($body);
         }
         if (!empty($info['outbound_mails_reply_link']) && $info['outbound_mails_reply_link'] === 'y') {
             $body = preg_replace('/^.*?Reply Link\\: \\<[^\\>]*\\>.*\\r?\\n/m', '', $body);
             // remove previous reply links to reduce clutter and confusion
             // remove "empty" lines at the end
             $lines = preg_split("/(\r\n|\n|\r)/", $body);
             $body = '';
             $len = count($lines) - 1;
             $found = false;
             for ($line = $len; $line >= 0; $line--) {
                 if ($found || !preg_match('/^\\s*\\>*\\s*[\\-]*\\s*$/', $lines[$line])) {
                     $body = "{$lines[$line]}\r\n{$body}";
                     $found = true;
                 }
             }
         }
         // Remove 're:' and [forum]. -rlpowell
         $title = trim(preg_replace("/[rR][eE]:/", "", preg_replace("/\\[[-A-Za-z _:]*\\]/", "", $output['header']['subject'])));
         $title = $mimelib->cleanQuotes($title);
         // trim off < and > from message-id
         $message_id = substr($output['header']["message-id"], 1, strlen($output['header']["message-id"]) - 2);
         if (isset($output['header']["in-reply-to"])) {
             $in_reply_to = substr($output['header']["in-reply-to"], 1, strlen($output['header']["in-reply-to"]) - 2);
         } else {
             $in_reply_to = '';
         }
         // Determine user from email
         $userName = $this->table('users_users')->fetchOne('login', array('email' => $email));
         //use anonomus name feature if we don't have a real name
         if (!$userName) {
             $anonName = $original_email;
         }
         //Todo: check permissions
         // Determine if the thread already exists first by looking for a mail this is a reply to.
         if (!empty($in_reply_to)) {
             $parentId = $this->table('tiki_comments')->fetchOne('threadId', array('object' => $forumId, 'objectType' => 'forum', 'message_id' => $in_reply_to));
         } else {
             $parentId = 0;
         }
         // if not, check if there's a topic with exactly this title
         if (!$parentId) {
             $parentId = $this->table('tiki_comments')->fetchOne('threadId', array('object' => $forumId, 'objectType' => 'forum', 'parentId' => 0, 'title' => $title));
         }
         if (!$parentId) {
             // create a thread to discuss a wiki page if the feature is on AND the page exists
             if ($prefs['feature_wiki_discuss'] === 'y' && TikiLib::lib('tiki')->page_exists($title)) {
                 // No thread already; create it.
                 $temp_msid = '';
                 $parentId = $this->post_new_comment('forum:' . $forumId, 0, $userName, $title, sprintf(tra("Use this thread to discuss the %s page."), "(({$title}))"), $temp_msid, $in_reply_to);
                 $this->register_forum_post($forumId, 0);
                 // First post is in reply to this one
                 $in_reply_to = $temp_msid;
             } else {
                 $parentId = 0;
             }
         }
         // post
         $threadid = $this->post_new_comment('forum:' . $forumId, $parentId, $userName, $title, $body, $message_id, $in_reply_to, 'n', '', '', '', $anonName, $postDate);
         $this->register_forum_post($forumId, $parentId);
         // Process attachments
         if (array_key_exists('parts', $output) && count($output['parts']) > 1) {
             $forum_info = $this->get_forum($forumId);
             if ($forum_info['att'] != 'att_no') {
                 $errors = array();
                 foreach ($output['parts'] as $part) {
                     if (array_key_exists('disposition', $part)) {
                         if ($part['disposition'] == 'attachment') {
                             if (!empty($part['d_parameters']['filename'])) {
                                 $part_name = $part['d_parameters']['filename'];
                             } else {
                                 if (preg_match('/filename=([^;]*)/', $part['d_parameters']['atend'], $mm)) {
                                     // not sure what this is but it seems to have the filename in it
                                     $part_name = $mm[1];
                                 } else {
                                     $part_name = "Unnamed File";
                                 }
                             }
                             $this->add_thread_attachment($forum_info, $threadid, $errors, $part_name, $part['type'], strlen($part['body']), 1, '', '', $part['body']);
                         } elseif ($part['disposition'] == 'inline') {
                             if (!empty($part['parts'])) {
                                 foreach ($part['parts'] as $p) {
                                     $this->add_thread_attachment($forum_info, $threadid, $errors, '-', $p['type'], strlen($p['body']), 1, '', '', $p['body']);
                                 }
                             } else {
                                 if (!empty($part['body'])) {
                                     $this->add_thread_attachment($forum_info, $threadid, $errors, '-', $part['type'], strlen($part['body']), 1, '', '', $part['body']);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Deal with mail notifications.
         if (array_key_exists('outbound_mails_reply_link', $info) && $info['outbound_mails_for_inbound_mails'] == 'y') {
             include_once 'lib/notifications/notificationemaillib.php';
             sendForumEmailNotification('forum_post_thread', $threadid, $info, $title, $body, $userName, $title, $message_id, $in_reply_to, $threadid, $parentId);
         }
         $pop3->deleteMsg($i);
     }
     $pop3->disconnect();
 }
예제 #9
0
 */
/* SOAP_Server_Email */
require_once 'SOAP/Server/Email.php';
/* Include a class to access POP3. */
require_once 'Net/POP3.php';
/* Create the SOAP Server object. */
$server = new SOAP_Server_Email();
/* Tell the server to translate to classes we provide if possible. */
$server->_auto_translation = true;
require_once './example_server.php';
$soapclass = new SOAP_Example_Server();
$server->addObjectMap($soapclass, 'urn:SOAP_Example_Server');
/* Connect to a POP3 server and read the messages. */
$pop3 = new Net_POP3();
if ($pop3->connect('localhost', 110)) {
    if ($pop3->login('username', 'password')) {
        $listing = $pop3->getListing();
        /* Now loop through each message, and call the SOAP server with that
         * message. */
        foreach ($listing as $msg) {
            $email = $pop3->getMsg($msg['msg_id']);
            /* This is where we actually handle the SOAP response.  The
             * SOAP_Server_Email class we are using will send the SOAP
             * response to the sender via email. */
            if ($email) {
                $server->client($email);
                $pop3->deleteMsg($msg['msg_id']);
            }
        }
    }
    $pop3->disconnect();
예제 #10
0
 private static function _connect($mfolder)
 {
     static $cache = array();
     if (empty($cache[$mfolder])) {
         $creds = sys_credentials($mfolder);
         if ($creds["server"] == "") {
             return false;
         }
         if (!$creds["port"]) {
             $creds["port"] = 110;
         }
         if ($creds["ssl"] and !extension_loaded("openssl")) {
             sys_warning(sprintf("{t}%s is not compiled / loaded into PHP.{/t}", "OpenSSL"));
             return false;
         }
         $pop3 = new Net_POP3();
         if (PEAR::isError($result = $pop3->connect($creds["ssl"] ? $creds["ssl"] . "://" . $creds["server"] : $creds["server"], $creds["port"]))) {
             sys_warning(sprintf("{t}Connection error: %s [%s]{/t}", $result->getMessage(), "POP3"));
             return false;
         }
         if (PEAR::isError($ret = $pop3->login($creds["username"], $creds["password"], "USER"))) {
             sys_warning(sprintf("{t}Pop3-error: %s{/t}", $ret->getMessage()));
             return false;
         }
         $cache[$mfolder] = $pop3;
     }
     return $cache[$mfolder];
 }
예제 #11
0
 function execute()
 {
     global $PIVOTX;
     if (!$this->active) {
         return;
     }
     $messages[] = "Checking email..";
     // Create the class and fetch the list of available emails..
     if ($this->cfg['use_imap']) {
         $mail = new Mail();
         $protocol = strtolower(substr($this->cfg['imap_protocol'], 0, 4));
         if (str_replace($protocol, '', $this->cfg['imap_protocol']) == 's') {
             $secure = true;
         } else {
             $secure = false;
         }
         $server = array('type' => $protocol, 'server' => $this->cfg['server'], 'secure' => $secure, 'mailbox' => $this->cfg['imap_mailbox'], 'username' => $this->cfg['username'], 'password' => $this->cfg['password']);
         if (!$mail->connect($server)) {
             debug("Moblog: No connection (using IMAP extension).");
             exit(1);
         } else {
             $messages[] = "Moblog: OK connection (using IMAP extension).\n";
         }
         $mail->parse_messages();
         if (is_array($mail->messages)) {
             $listing = $mail->messages;
         } else {
             $listing = array();
         }
     } else {
         $pop3 = new Net_POP3();
         $ret = $pop3->connect($this->cfg['server'], $this->cfg['pop_port']);
         if (!$ret) {
             debug("Moblog: No connection.");
             exit(1);
         } elseif (PEAR::isError($ret = $pop3->login($this->cfg['username'], $this->cfg['password'], 'USER'))) {
             debug("Moblog: error logging in: " . $ret->getMessage());
             exit(1);
         } else {
             $messages[] = "Moblog: OK connection.\n";
         }
         $listing = $pop3->getListing();
     }
     $messages[] = count($listing) . " email found on the server.";
     $regen = false;
     // Then we iterate through the list..
     foreach ($listing as $list_item) {
         if ($this->cfg['use_imap']) {
             $msg_id = $list_item['message_id'];
             $email = $list_item['rawdata'];
         } else {
             $msg_id = $list_item['msg_id'];
             $email = $pop3->getMsg($msg_id);
         }
         $messages[] = "fetched mail {$msg_id}";
         if (!$this->cfg['leave_on_server']) {
             if ($this->cfg['use_imap']) {
                 $mail->delete($list_item['msgno']);
             } else {
                 $pop3->deleteMsg($msg_id);
             }
             $messages[] = "Message was deleted from the server..";
         } else {
             $messages[] = "Message was left on the server (if supported)..";
         }
         // Perhaps save a local copy..
         if ($this->cfg['save_mail']) {
             $maildir = $PIVOTX['paths']['db_path'] . 'mail/';
             if (!file_exists($maildir)) {
                 makeDir($maildir);
             }
             $msg_id = str_replace(array('<', '>'), '', $msg_id);
             $filename = $maildir . date("Ymd-His") . "-" . $msg_id . ".eml";
             if ($fp = fopen($filename, "w")) {
                 fwrite($fp, $email);
                 $messages[] = "Local copy saved as: {$filename}";
                 fclose($fp);
             } else {
                 $messages[] = "Alas! Woe is me! I couldn't save a local copy.";
             }
         }
         $this->entry = array();
         // Parse and post the email..
         $this->parse_email($email);
         $messages[] = $this->compose_entry();
         $regen = true;
     }
     if ($this->cfg['use_imap']) {
         $mail->close();
     } else {
         $pop3->disconnect();
     }
     if ($regen) {
         // Clear cache?
         // $messages[] = "Cleared cache after adding new moblog entry";
     }
     $messages[] = "Done!";
     return $messages;
 }
예제 #12
0
파일: pop.php 프로젝트: rdmpage/bioguid
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_USERPWD, "{$username}:{$password}");
    if ($config['proxy_name'] != '') {
        curl_setopt($ch, CURLOPT_PROXY, $config['proxy_name'] . ':' . $config['proxy_port']);
    }
}
// initialize object
$pop3 = new Net_POP3();
// attempt connection to server
if (!$pop3->connect("udcf.gla.ac.uk", 110)) {
    die("Error in connection");
}
// attempt login
$ret = $pop3->login("dpage", "peacrab");
if (is_a($ret, 'PEAR_Error')) {
    die("Error in authentication: " . $ret->getMessage());
}
// print number of messages found
echo $pop3->numMsg() . " message(s) in mailbox\n";
// print message headers
if ($pop3->numMsg() > 0) {
    for ($x = 1; $x <= $pop3->numMsg(); $x++) {
        $hdrs = $pop3->getParsedHeaders($x);
        print_r($hdrs);
        //echo $hdrs['From'] . "\n" . $hdrs['Subject'] . "\n" . $hdrs['Message-Id'] . "\n\n";
        $count = 0;
        // Only process emails from xxx.
        //        if (preg_match('/evoldir\@evol.biology.mcmaster.ca/', $pop3->getBody($x)))
        if (preg_match('/evoldir\\@evol.biology.mcmaster.ca/', $hdrs['From'])) {
예제 #13
0
        } else {
            echo "No contact found in iTop having the email: {$sSenderEmail}, email message ignored.\n";
        }
    } catch (Exception $e) {
        echo "Error: exception " . $e->getMessage();
        $oTicket = null;
    }
    return $oTicket;
}
/**
 * Main program
 */
// Connect to the POP3 server & open the mailbox
$oPop3 = new Net_POP3();
$oPop3->connect(MAILBOX_SERVER, MAILBOX_SERVER_PORT);
$oPop3->login(MAILBOX_ACCOUNT, MAILBOX_PASSWORD);
// Read all the messages from the mailbox and tries to create a new ticket for each one
// Note: it is expected that the sender of the email exists a valid contact as a 'Contact'
// in iTop (identified by her/his email address), otherwise the ticket creation will fail
$iNbMessages = $oPop3->numMsg();
for ($index = 1; $index <= $iNbMessages; $index++) {
    $params['include_bodies'] = true;
    $params['decode_bodies'] = true;
    $params['decode_headers'] = true;
    $params['crlf'] = "\r\n";
    $aHeaders = $oPop3->getParsedHeaders($index);
    $aSender = GetSender($aHeaders);
    $oDecoder = new Mail_mimeDecode($oPop3->getRawHeaders($index) . $params['crlf'] . $oPop3->getBody($index));
    $oStructure = $oDecoder->decode($params);
    $sSubject = $aHeaders['Subject'];
    // Search for the text/plain body part
예제 #14
0
 function email_pop_subscription($host, $port = 995, $login, $password, $list_ID)
 {
     $pop3 = new Net_POP3();
     if (!$pop3->connect('ssl://' . $host, $port)) {
         die('could not log in');
     }
     $pop3->login($login, $password);
     $size = $pop3->numMsg();
     if ($size >= 1) {
         $x = 1;
         while ($x <= $size) {
             $headers = $pop3->getParsedHeaders($x);
             add_email_user($list_ID, $headers['From']);
             $pop3->deleteMsg($x);
             $x++;
         }
     }
     $pop3->disconnect();
 }
예제 #15
0
function val_email_staff($email, $paswd, $descp, $compulsory = 0)
{
    $errors = '';
    if ($compulsory && empty($email)) {
        $errors = val_isEmpty($email, $descp . " email");
    } elseif (!empty($email)) {
        include_once 'Net/POP3.php';
        $pop3 = new Net_POP3();
        //	インスタンス作成
        $respC = $pop3->connect(POPSERVER, POP3);
        // 	接続 一回目
        if ($respC === false) {
            sleep(1);
            $respC = $pop3->connect(POPSERVER, PORT);
            // 	接続 二回目
            if ($respC === false) {
                sleep(2);
                $respC = $pop3->connect(POPSERVER, PORT);
                // 	接続 三回目
                if ($respC === false) {
                    sleep(3);
                    $respC = $pop3->connect(POPSERVER, PORT);
                    // 	接続 四回目
                    if ($respC === false) {
                        $errors = "The " . $descp . " email address can`t connect server.";
                    }
                }
            }
        }
    }
    if (empty($errors)) {
        $respL = $pop3->login($email, $paswd, 'USER');
        // 	ログイン ( APOP )
        if ($respL === false) {
            sleep(1);
            $respL = $pop3->login($email, $paswd, 'USER');
            // 	ログイン ( APOP )
            if ($respL === false) {
                $errors = "The " . $descp . " email address is not a valid.  (can't login to server).";
                return $errors;
            }
        }
        $mailNum = $pop3->numMsg();
        // 	メール総件数
        if (!is_int($mailNum)) {
            $errors = "The " . $descp . " email address is not a valid.  (Perhaps the email is not registered).";
        }
    }
    return $errors;
}
예제 #16
0
 function sms_pop_subscription($host, $port = 995, $login, $password, $list_ID)
 {
     $pop3 = new Net_POP3();
     if (!$pop3->connect('ssl://' . $host, $port)) {
         die('could not log in');
     }
     $pop3->login($login, $password);
     $size = $pop3->numMsg();
     if ($size >= 1) {
         $x = 1;
         while ($x <= $size) {
             $headers = $pop3->getParsedHeaders($x);
             $number = $this->parse_email($headers['From']);
             echo $number['number'] . $number['carrier'];
             $this->add_user_sms($list_ID, $number['number'], $number['carrier']);
             $pop3->deleteMsg($x);
             $x++;
         }
     }
     $pop3->disconnect();
 }