* @about Developed in whole or part by the U.S. National Library of Medicine * @link https://pl.nlm.nih.gov/about * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) * @lastModified 2011.0308 */ //error_reporting(E_STRICT); ini_set( "display_errors", "stdout"); error_reporting(E_ALL); // set approot since we don't know it yet $global['approot'] = getcwd()."/../../"; // include required libraries require_once("../../mod/lpf/lib_lpf.inc"); require_once("../../conf/sahana.conf"); require_once("../../3rd/adodb/adodb.inc.php"); require_once("../../inc/handler_db.inc"); require_once("../../inc/lib_uuid.inc"); require_once("../../inc/lib_image.inc"); $body = "Here is a test message."; echo "ok\n"; $p = new pop(); $p->sendMessage("*****@*****.**", "*****@*****.**", "subject", $body, $body); echo $p->spit();
private function loopInbox() { global $global; // download all message information from inbox $this->overview = imap_fetch_overview($this->mailbox, "1:" . $this->messageCount, 0); $this->size = sizeof($this->overview); // loop through each message for ($i = $this->size - 1; $i >= 0; $i--) { $raw = imap_fetchstructure($this->mailbox, $i); error_log("DUMPPPPPP::>>" . var_export($raw) . "<<::::"); $this->person = null; // clear out the last person... $this->person = new person(); $this->person->init(); $this->person->rep_uuid = 2; $this->ecode = 0; $this->toggleActivity = true; // retrieve current message's data $this->currentMessage = $this->overview[$i]; $this->currentSubject = $this->currentMessage->subject; $this->currentDate = $this->currentMessage->date; $this->currentFrom = $this->currentMessage->from; $this->currentAttachments = null; // reset from last person $this->currentAttachments = array(); $this->currentMessageHasXML = false; $this->senderAddress = $this->overview[$i]->from; $this->fixDate(); // reformat the date for our purposes $this->fixFrom(); // strip extra characters from the from field $this->fixAddress(); // fix email address of excess characters $this->getAttachmentsAndParseXML($i); // grab all attachments $this->messages .= "From: " . $this->currentFrom . "<br>"; $this->messages .= "Subject: " . $this->currentSubject . "<br>"; // Time Sensitive Action Required: NIH Password Expires on 04/04/2012 19:07:11 $needle[] = "/Time Sensitive Action Required/"; if (preg_match($needle[$i], $this->currentSubject) > 0) { global $conf; $body = "Please update the password on this account before it expires: <b>" . shn_db_get_config("mpres", "username") . "</b><br><br>Email Subject:<br>" . $this->currentSubject; $p = new pop(); $p->sendMessage($conf['audit_email'], "", "{ " . $conf['site_name'] . " Password Expiration Notice }", $body, $body); echo $p->spit(); // email has XML attachment.... } elseif ($this->currentMessageHasXML) { // catch all parsing errors... if ($this->ecode != 0) { $this->messages .= "LPF XML email found but failed during parsing with error code: " . $this->ecode . ".<br>"; $this->replyError("Your person record was successfully received, but we failed to parse the XML. Please report this to lpfsupport@mail.nih.gov"); // event is closed... error } elseif (!$this->person->isEventOpen()) { $this->messages .= "LPF XML email found however, the event being reported to is closed, so the person was not inserted.<br>"; $this->replyError("Your person record was successfully received, but the event you are reporting to is closed so the record was not inserted."); // insert! } else { $this->person->insert(); $this->mpresLog(); $this->messages .= "LPF XML email found and person <a href=\"https://" . $this->person->p_uuid . "\" target=\"_blank\">" . $this->person->p_uuid . "</a> inserted.<br>"; $this->replySuccess($this->person->p_uuid, $this->person->incident_id); } // unstructured email... attempt to parse subject } else { $this->person->incident_id = $this->incident_id; if (!$this->person->isEventOpen()) { $this->messages .= "Unstructured email found, however the event being reported to is closed, so the person was not inserted.<br>"; $this->replyError("We are not accepting email reports at this time. Sorry, but your person was not inserted into our system."); } else { $this->person->createUUID(); $this->extractStatusFromSubject(); $name = new nameParser($this->currentSubject); $this->person->given_name = $name->getFirstName(); $this->person->family_name = $name->getLastName(); $this->person->full_name = $this->person->given_name . " " . $this->person->family_name; $this->person->last_updated = date('Y-m-d H:i:s'); $this->person->creation_time = date('Y-m-d H:i:s'); $this->person->author_name = $this->currentFrom; $this->person->author_email = $this->currentFrom; $this->person->xmlFormat = "MPRES"; $this->person->arrival_vanilla_email = true; $this->person->insert(); $this->mpresLog(); $this->messages .= "Unstructured email found and person <a href=\"https://" . $this->person->p_uuid . "\" target=\"_blank\">" . $this->person->p_uuid . "</a> inserted.<br>"; $this->replySuccess($this->person->p_uuid, $this->person->incident_id); } } // delete the message from the inbox imap_delete($this->mailbox, $i + 1); $this->messages .= "Message #" . $i . " deleted.<br>"; } }