public function readEmails($sentTo = null, $bodyPart = null) { $host = '{imap.gmail.com:993/imap/ssl}INBOX'; $spinner = new Spinner('Could not connect to Imap server.', 60, 10000); $inbox = $spinner->assertBecomesTrue(function () use($host) { return @imap_open($host, $this->email, $this->password); }); $emails = imap_search($inbox, 'TO ' . ($sentTo ? $sentTo : $this->email)); if ($emails) { $messages = []; foreach ($emails as $n) { $structure = imap_fetchstructure($inbox, $n); if (!$bodyPart) { $part = $this->findPart($structure, function ($part) { return $part->subtype === 'HTML'; }); } elseif (is_callable($bodyPart)) { $part = $this->findPart($structure, $bodyPart); } else { $part = $bodyPart; } $hinfo = imap_headerinfo($inbox, $n); $subject = $hinfo->subject; $message = ['subject' => $subject, 'body' => imap_fetchbody($inbox, $n, $part)]; $messages[] = $message; } return $messages; } else { return []; } }
/** * Get messages according to a search criteria * * @param string search criteria (RFC2060, sec. 6.4.4). Set to "UNSEEN" by default NB: Search criteria only affects IMAP mailboxes. * @param string date format. Set to "Y-m-d H:i:s" by default * @return mixed array containing messages */ public function get_messages($search_criteria = "UNSEEN", $date_format = "Y-m-d H:i:s") { $msgs = imap_search($this->imap_stream, $search_criteria); $no_of_msgs = $msgs ? count($msgs) : 0; $messages = array(); for ($i = 0; $i < $no_of_msgs; $i++) { $header = imap_header($this->imap_stream, $msgs[$i]); $date = date($date_format, $header->udate); $from = $this->_mime_decode($header->fromaddress); $subject = $this->_mime_decode($header->subject); $structure = imap_fetchstructure($this->imap_stream, $msgs[$i]); if (!empty($structure->parts)) { for ($j = 0, $k = count($structure->parts); $j < $k; $j++) { $part = $structure->parts[$j]; if ($part->subtype == 'PLAIN') { $body = imap_fetchbody($this->imap_stream, $msgs[$i], $j + 1); } } } else { $body = imap_body($this->imap_stream, $msgs[$i]); } // Convert quoted-printable strings (RFC2045) $body = imap_qprint($body); array_push($messages, array('msg_no' => $msgs[$i], 'date' => $date, 'from' => $from, 'subject' => $subject, 'body' => $body)); } return $messages; }
function inbox() { $this->msg_cnt = imap_num_msg($this->conn); echo "Number of emails read = " . $this->msg_cnt . "\n"; /*$in = array(); for($i = 1; $i <= $this->msg_cnt; $i++) { $in[] = array( 'index' => $i, 'header' => imap_headerinfo($this->conn, $i), 'body' => imap_body($this->conn, $i), 'structure' => imap_fetchstructure($this->conn, $i) ); */ $output = '<table>'; $output .= '<tr><th>Subject</th><th>voucher</th><th>From</th><th>seen</th><th>type</th></tr>'; $mails = imap_search($this->conn, 'FROM "*****@*****.**" SUBJECT "Confirm Hotel Booking"'); //print_r($mails); for ($i = 0; $i <= sizeof($mails); $i++) { $header = imap_fetch_overview($this->conn, $mails[$i], 0); $body = imap_fetchbody($this->conn, $mails[$i], 1.1); $output .= '<tr>'; $output .= '<td><span class="subject">' . $header[0]->subject . '</span> </td>'; $output .= '<td><span class="from">' . $header[0]->from . '</span></td>'; $output .= '<td><span class="voucher">' . $mails[0]->voucher . '</span></td>'; $output .= '<td><span class="date">' . $header[0]->date . '</span></td>>'; $output .= '<td><span class="toggler">' . ($header[0]->seen ? 'read' : 'unread') . '"></span></td>'; $structure = imap_fetchstructure($this->conn, $mails[$i]); $output .= '<td><span class="type">' . $structure->type . '</span> </td>'; $output .= '</tr>'; } $output .= '</table>'; echo $output . "\n"; }
/** * @param string $criteria * @return $this */ public function messages($criteria) { $this->messages = array_map(function ($messageNumber) { return array('id' => $messageNumber, 'header' => imap_header($this->mailbox, $messageNumber), 'struct' => imap_fetchstructure($this->mailbox, $messageNumber)); }, imap_search($this->mailbox, $criteria)); return $this; }
public function BuscarMails($from, $readCommand) { $emails = null; if ($this->Open()) { $command = $readCommand . " FROM '" . $from . "'"; $emails = imap_search($this->imap_client, $command); } return $emails; }
public static function emailDeliverFailBySubject($subject) { $mailcnf = "outlook.office365.com:993/imap/ssl/novalidate-cert"; $username = MAILACCOUNT; $pw = MAILPASSWORD; $conn_str = "{" . $mailcnf . "}INBOX"; $inbox = imap_open($conn_str, $username, $pw) or die('Cannot connect to mail: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox, 'SUBJECT "Undeliverable: ' . $subject . '"'); $failedInfo = []; /* if emails are returned, cycle through each... */ if ($emails) { /* for every email... */ foreach ($emails as $email_number) { /* get information specific to this email */ $body = imap_fetchbody($inbox, $email_number, 2); $list = split('; ', $body); $sender = $list[2]; $sender_email = explode("\n", $sender)[0]; array_push($failedInfo, trim($sender_email)); } } /* close the connection */ imap_close($inbox); return $failedInfo; }
private function getMails() { $mails = array(); if ($this->createConnection()) { $unseen = imap_search($this->connection, 'UNSEEN'); // fetch only unseen mails... much faster $index = ''; if ($unseen) { foreach ($unseen as $uMail) { $index .= $uMail . ","; } } $mails = array_reverse(imap_fetch_overview($this->connection, "{$index}")); } $this->closeConnection(); $cleanMails = array(); foreach ($mails as $mail) { $tmp = array(); $tmp['subject'] = $this->decodeSubject($mail->subject); $tmp['from'] = $this->decodeSubject($mail->from); $datetime = new DateTime($mail->date); $tmp['datetime'] = $datetime->getTimestamp() + $datetime->getOffset(); $cleanMails[] = $tmp; } return $cleanMails; }
function search($criteria, $options = SE_FREE) { if ($this->mbox) { return imap_search($this->mbox, $criteria, $options); } return false; }
/** * Gets IMAP content * * @param string $imapHost * @param string $imapUser * @param string $imapPassword * @param \Swiftriver\Core\ObjectModel\Channel $channel * * @return $contentItems[] */ private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel) { $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword); //Open up unseen messages $imapEmails = imap_search($imapResource, strtoupper($channel->subType)); $contentItems = array(); if ($imapEmails) { //Put newest emails on top rsort($imapEmails); foreach ($imapEmails as $Email) { //Loop through each email and return the content $email_overview = imap_fetch_overview($imapResource, $Email, 0); $email_message = imap_fetchbody($imapResource, $Email, 2); $source_name = $imapUser; $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name); $source->name = $source_name; $source->parent = $channel->id; $source->type = $channel->type; $source->subType = $channel->subType; $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source); $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message)); //the message $item->link = null; $item->date = $email_overview[0]->date; $contentItems[] = $item; } imap_close($imapResource); return $contentItems; } imap_close($imapResource); return null; }
function readImapStatus($config, $savedStatus, $db) { $mbox = imap_open($config["imap_server"], $config["imap_user"], $config["imap_password"]); $imapStatus = imap_status($mbox, $config["imap_server"], SA_ALL); // Read message IDs of UNSEEN mails $unseen = []; if ($imapStatus->unseen > 0) { $messages = imap_search($mbox, "UNSEEN"); foreach ($messages as $msgID) { $msg = imap_headerinfo($mbox, $msgID); $unseen[] = $msg->message_id; } } imap_close($mbox); // $last_unseen = json_decode($savedStatus->unseen); $new_message_found = false; foreach ($unseen as $key => $value) { // Does 'unseen' contain msgID we haven't seen before? if (array_search($value, $last_unseen) === FALSE) { $new_message_found = true; } } // Current unseen list doesn't match saved one if (count($unseen) != count($last_unseen) || $new_message_found) { saveStatusToSqlite($db, "unseen", json_encode($unseen)); } return $new_message_found; }
function get_exchange($imap_box) { $emails = imap_search($imap_box, "FROM 'e-mail address'"); //ищем письма от //$emails = imap_search($imap_box, "FROM 'e-mail address'"); //ищем письма от //echo "<br>"; //if ($emails) echo "Найдено:" . sizeof($emails) . " писем.<br>"; // сколько нашли и какие их номера начиная с 0 //else echo "Писем удовлетворяющих условию не найдено."; $result = false; if ($emails) { /* put the newest emails on top */ rsort($emails); /* for every email... */ foreach ($emails as $email_number) { $message = get_msg($imap_box, $email_number, "PLAIN"); // PLAIN or HTML or ... $message = preg_replace('/\\r\\n|\\r|\\n/u', '', $message); // удаляем символы перевода строки preg_match("/Курс виписки рахунків- \\d\\d\\,\\d\\dГотівковий- \\d\\d\\,\\d\\d/", $message, $output_array); //ищем паттерн if ($output_array[0]) { // Если нашли паттерн if (!$result) { preg_match_all('/\\d\\d\\,\\d\\d/', $output_array[0], $result); } //нашли свежак и сохраняем его imap_delete($imap_box, $email_number); //помечаем письмо на удаление } } } imap_expunge($imap_box); return $result[0]; }
/** * Gets IMAP content * * @param string $imapHost * @param string $imapUser * @param string $imapPassword * @param \Swiftriver\Core\ObjectModel\Channel $channel * * @return $contentItems[] */ private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel) { $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword); //Open up unseen messages $search = $channel->lastSuccess == null ? "UNSEEN" : "UNSEEN SINCE " . \date("Y-m-d", $channel->lastSuccess); $imapEmails = imap_search($imapResource, $search); $contentItems = array(); if ($imapEmails) { //Put newest emails on top rsort($imapEmails); foreach ($imapEmails as $Email) { //Loop through each email and return the content $email_overview = imap_fetch_overview($imapResource, $Email, 0); if (strtotime(reset($email_overview)->date) < $channel->lastSuccess) { continue; } $email_header_info = imap_header($imapResource, $Email); $email_message = imap_fetchbody($imapResource, $Email, 1); $source_name = \reset($email_overview)->from; $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name); $source->name = $source_name; $source->parent = $channel->id; $source->type = $channel->type; $source->subType = $channel->subType; $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source); $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message)); //the message $item->link = null; $item->date = $email_header_info->udate; $contentItems[] = $item; } } imap_close($imapResource); return $contentItems; }
function emailListener() { $connection = establishConnection(); $dbConn = establishDBConnection(); $messagestatus = "UNSEEN"; $emails = imap_search($connection, $messagestatus); if ($emails) { rsort($emails); foreach ($emails as $email_number) { // echo "in email loop"; $header = imap_headerinfo($connection, $email_number); $message = imap_fetchbody($connection, $email_number, 1.1); if ($message == "") { $message = imap_fetchbody($connection, $email_number, 1); } $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1)); if (!detectOOOmessage($header->subject, $message, $emailaddress)) { detectBIOmessage($header->subject, $emailaddress); } imap_delete($connection, 1); //this might bug out but should delete the top message that was just parsed } } $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(NOW(), INTERVAL -1 DAY) limit 1"); //delete mentors that have been away for more than 24 hours from the away list }
/** * Primary method for downloading and processing email replies */ public function download_and_process_email_replies($connection_details) { imap_timeout(IMAP_OPENTIMEOUT, apply_filters('supportflow_imap_open_timeout', 5)); $ssl = $connection_details['imap_ssl'] ? '/ssl' : ''; $ssl = apply_filters('supportflow_imap_ssl', $ssl, $connection_details['imap_host']); $mailbox = "{{$connection_details['imap_host']}:{$connection_details['imap_port']}{$ssl}}"; $inbox = "{$mailbox}{$connection_details['inbox']}"; $archive_box = "{$mailbox}{$connection_details['archive']}"; $imap_connection = imap_open($mailbox, $connection_details['username'], $connection_details['password']); $redacted_connection_details = $connection_details; $redacted_connection_details['password'] = '******'; // redact the password to avoid unnecessarily exposing it in logs $imap_errors = imap_errors(); SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $imap_connection ? __('Successfully opened IMAP connection.', 'supportflow') : __('Failed to open IMAP connection.', 'supportflow'), compact('redacted_connection_details', 'mailbox', 'imap_errors')); if (!$imap_connection) { return new WP_Error('connection-error', __('Error connecting to mailbox', 'supportflow')); } // Check to see if the archive mailbox exists, and create it if it doesn't $mailboxes = imap_getmailboxes($imap_connection, $mailbox, '*'); if (!wp_filter_object_list($mailboxes, array('name' => $archive_box))) { imap_createmailbox($imap_connection, $archive_box); } // Make sure here are new emails to process $email_count = imap_num_msg($imap_connection); if ($email_count < 1) { SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('No new messages to process.', 'supportflow'), compact('mailboxes')); return false; } $emails = imap_search($imap_connection, 'ALL', SE_UID); $email_count = min($email_count, apply_filters('supportflow_max_email_process_count', 20)); $emails = array_slice($emails, 0, $email_count); $processed = 0; // Process each new email and put it in the archive mailbox when done. foreach ($emails as $uid) { $email = new stdClass(); $email->uid = $uid; $email->msgno = imap_msgno($imap_connection, $email->uid); $email->headers = imap_headerinfo($imap_connection, $email->msgno); $email->structure = imap_fetchstructure($imap_connection, $email->msgno); $email->body = $this->get_body_from_connection($imap_connection, $email->msgno); if (0 === strcasecmp($connection_details['username'], $email->headers->from[0]->mailbox . '@' . $email->headers->from[0]->host)) { $connection_details['password'] = '******'; // redact the password to avoid unnecessarily exposing it in logs SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('Skipping message because it was sent from a SupportFlow account.', 'supportflow'), compact('email')); continue; } // @todo Confirm this a message we want to process $result = $this->process_email($imap_connection, $email, $email->msgno, $connection_details['username'], $connection_details['account_id']); // If it was successful, move the email to the archive if ($result) { imap_mail_move($imap_connection, $email->uid, $connection_details['archive'], CP_UID); $processed++; } } imap_close($imap_connection, CL_EXPUNGE); $status_message = sprintf(__('Processed %d emails', 'supportflow'), $processed); SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $status_message); return $status_message; }
public function totalUnread() { $res = imap_search($this->mailbox, 'UNSEEN'); if ($res === false) { return 0; } return count($res); }
function imap_unread() { $m_gdmy = "20-March-2014"; $m_search = imap_search($this->conn, 'UNSEEN SINCE ' . $m_gdmy . ''); //If mailbox is empty......Display "No New Messages", else........ You got mail....oh joy $count = count($m_search) > 0 ? count($m_search) : 0; return $count; }
/** * @return array * @throws Exception */ public function getEmails() { $emails = imap_search($this->imap, 'ALL', SE_UID); if ($emails === false) { throw new Exception('Cannot get emails: ' . imap_last_error()); } return $emails; }
private function fetchEmails($mailbox, $criteria) { $emails = imap_search($mailbox, $criteria->getSearchString()); if (!$emails) { return false; } rsort($emails); return $emails; }
function tst($in) { if (!is_resource($in)) { echo 'no'; exit; } // search and get unseen emails, function will return email ids return imap_search($in, 'ALL UNSEEN'); }
public function getAllMessages() { $array = array(); $messages = imap_search($mbox, 'ALL'); foreach ($messages as $messsage) { $msg = new Mailbox_Message($this->connection); $msg->message_id = $message; } }
public function search($criteria = 'ALL') { debug::output("Starting Search..."); $emails = imap_search($this->imap, $criteria); if (!is_array($emails)) { throw new emailException(imap_last_error($this->imap), imap_errors($this->imap)); } else { return $emails; } }
/** * Returns a collection of messages matching the given search criteria * @link http://php.net/manual/en/function.imap-search.php * * @param string $criteria A string, delimited by spaces, * in which the following keywords are allowed. * Any multi-word arguments (e.g. FROM "joey smith") must be quoted. * Results will match all criteria entries. * ALL - return all messages matching the rest of the criteria * ANSWERED - match messages with the \\ANSWERED flag set * BCC "string" - match messages with "string" in the Bcc: field * BEFORE "date" - match messages with Date: before "date" * BODY "string" - match messages with "string" in the body of the message * CC "string" - match messages with "string" in the Cc: field * DELETED - match deleted messages * FLAGGED - match messages with the \\FLAGGED (sometimes referred to as Important or Urgent) flag set * FROM "string" - match messages with "string" in the From: field * KEYWORD "string" - match messages with "string" as a keyword * NEW - match new messages * OLD - match old messages * ON "date" - match messages with Date: matching "date" * RECENT - match messages with the \\RECENT flag set * SEEN - match messages that have been read (the \\SEEN flag is set) * SINCE "date" - match messages with Date: after "date" * SUBJECT "string" - match messages with "string" in the Subject: * TEXT "string" - match messages with text "string" * TO "string" - match messages with "string" in the To: * UNANSWERED - match messages that have not been answered * UNDELETED - match messages that are not deleted * UNFLAGGED - match messages that are not flagged * UNKEYWORD "string" - match messages that do not have the keyword "string" * UNSEEN - match messages which have not been read yet * @return MessageCollection messages collection */ public function search($criteria) { $messages = new MessageCollection(); if ($results = imap_search($this->stream, $criteria, SE_UID)) { foreach ($results as $result) { $messages->add(new Message($this->stream, $result)); } } return $messages; }
/** * Get message ids * * @param SearchExpression $search Search expression (optional) * * @return MessageIterator|Message[] */ public function getMessages(SearchExpression $search = null) { $this->init(); $query = $search ? (string) $search : 'ALL'; $messageNumbers = \imap_search($this->connection->getResource(), $query, \SE_UID); if (false == $messageNumbers) { // \imap_search can also return false $messageNumbers = array(); } return new MessageIterator($this->connection->getResource(), $messageNumbers); }
/** * @param string $criteria * @param int $options * @param int $charset * @return IMAPMessage[] * @throws Exception */ public function search($criteria, $options = NULL, $charset = NULL) { $emails = imap_search($this->stream, $criteria); if (FALSE === $emails) { throw new Exception('Search failed: ' . imap_last_error()); } foreach ($emails as &$email) { $email = $this->getMessageByNumber($email); } return $emails; }
function CheckMail() { echo "===========================\n"; echo " CHECK MAIL\n"; echo "===========================\n"; global $rawDIR, $nowGradeFile, $now; // $outFile=fopen($nowGradeFile,"w"); $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $username = "******"; $password = '******'; /* try to connect */ $inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error()); /* grab emails */ // $emails = imap_search($inbox, 'ALL', '*****@*****.**'); $emails = imap_search($inbox, 'FROM noreply@wcasd.net'); /* if emails are returned, cycle through each... */ if ($emails) { /* begin output var */ $output = ''; /* put the newest emails on top */ // rsort($emails); /* for every email... */ foreach ($emails as $email_number) { /* get information specific to this email */ $overview = imap_fetch_overview($inbox, $email_number, 0); // if ( $overview[0]->from == "*****@*****.**" && $overview[0]->seen == 0 ) { // if ( $overview[0]->from == "*****@*****.**" ) { $output .= "Number: {$email_number}\n"; $output .= "From: " . $overview[0]->from . "\n"; $output .= "Subject: " . $overview[0]->subject . "\n"; $output .= "Seen: " . $overview[0]->seen . "\n"; $output .= "Date: " . $overview[0]->date . "\n"; $message = imap_fetchbody($inbox, $email_number, 1); // $message = imap_body($inbox, $email_number, 'FT_PEEK'); // echo "MESSAGE: ". $message; $outFile = fopen($nowGradeFile, "w"); fwrite($outFile, $message); fclose($outFile); if (file_exists($nowGradeFile)) { echo "Wrote {$nowGradeFile}.\n"; } else { echo "Failed to write {$nowGradeFile}.\n"; } // imap_setflag_full($inbox, $email_number, 'unseen'); // imap_mail_move($inbox, "$email_number", 'School'); // break; // } } } /* close the connection */ imap_close($inbox); echo "{$output}\n"; exit; }
protected function open($searchType) { if ($this->inbox = imap_open($this->access, $this->user, $this->pass)) { $this->mids = imap_search($this->inbox, $searchType); $this->midCount = count($this->mids); if ($this->midCount == 1 && empty($this->mids[$this->midCount - 1])) { $this->midCount = 0; } } else { $this->error = MinionError::LOGIN_FAILED; } }
/** * Get message ids. * * @param Mirasvit_Ddeboer_Imap_SearchExpression|string $search Search expression (optional) * * @return Mirasvit_Ddeboer_Imap_MessageIterator */ public function getMessages($search = null) { $this->init(); $query = $search ? (string) $search : 'ALL'; // $messageNumbers = imap_search($this->connection->getResource(), $query, SE_UID); $messageNumbers = imap_search($this->connection->getResource(), $query); if (false == $messageNumbers) { // imap_search can also return false $messageNumbers = array(); } return new Mirasvit_Ddeboer_Imap_MessageIterator($this->connection->getResource(), $messageNumbers); }
public function fetch(ImapCriteria $criteria) { $messageUidList = \imap_search($this->imapResource, $criteria->getCriteria(), \SE_UID); if($messageUidList === false) { $messageUidList = array(); } $messageCollection = new ImapCollection($this->imapResource, $messageUidList); return $messageCollection; }
public function getMailBox() { $mailboxes = array('label' => 'Gmail', 'enable' => true, 'mailbox' => '{imap.gmail.com:993/ssl}[Gmail]/Sent Mail', 'username' => '*****@*****.**', 'password' => '4N?@vwJn@resijt'); $stream = imap_open($mailboxes['mailbox'], $mailboxes['username'], $mailboxes['password']); if (!$stream) { return 'err1'; //return Redirect::back()->withInput()->withErrors('An error occured. Please try again.'); } $emails = imap_search($stream, 'ALL'); if (!$emails) { return 'err2'; } else { rsort($emails); } $emailList = array(); $count = 0; foreach ($emails as $item) { $overview = imap_fetch_overview($stream, $item, 0); $emailList[$count] = $overview; $emailList[$count]['agoTime'] = Carbon::createFromTimestampUTC(strtotime($overview[0]->date))->diffForHumans(); $count++; } imap_close($stream); return $emailList; }
/** * Gets the mail from the inbox * Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox. */ function getMail() { $config = Config::current(); if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) { $hostname = '{' . $config->emailblog_server . '}INBOX'; # this isn't working well on localhost $username = $config->emailblog_address; $password = $config->emailblog_pass; $subjpass = $config->emailblog_subjpass; $inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error()); $emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"'); if ($emails) { rsort($emails); foreach ($emails as $email_number) { $message = imap_body($inbox, $email_number); $overview = imap_headerinfo($inbox, $email_number); imap_delete($inbox, $email_number); $title = htmlspecialchars($overview->Subject); $title = preg_replace($subjpass, "", $title); $clean = strtolower($title); $body = htmlspecialchars($message); # The subject of the email is used as the post title # the content of the email is used as the body # not sure about compatibility with images or audio feathers Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text"); } } # close the connection imap_close($inbox, CL_EXPUNGE); $config->set("emailblog_mail_checked", time()); } }