/** * 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++) { // Get Message Unique ID in case mail box changes // in the middle of this operation $message_id = imap_uid($this->imap_stream, $msgs[$i]); $header = imap_header($this->imap_stream, $message_id); $date = date($date_format, $header->udate); $from = $header->from; $fromname = ""; $fromaddress = ""; $subject = ""; foreach ($from as $id => $object) { if (isset($object->personal)) { $fromname = $object->personal; } $fromaddress = $object->mailbox . "@" . $object->host; if ($fromname == "") { // In case from object doesn't have Name $fromname = $fromaddress; } } if (isset($header->subject)) { $subject = $this->_mime_decode($header->subject); } $structure = imap_fetchstructure($this->imap_stream, $message_id); $body = ''; 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, $message_id, $j + 1); } } } else { $body = imap_body($this->imap_stream, $message_id); } // Convert quoted-printable strings (RFC2045) $body = imap_qprint($body); array_push($messages, array('msg_no' => $message_id, 'date' => $date, 'from' => $fromname, 'email' => $fromaddress, 'subject' => $subject, 'body' => $body)); // Mark Message As Read imap_setflag_full($this->imap_stream, $message_id, "\\Seen"); } return $messages; }
function readMessages($messages) { $mbox = getMbox(); $messages = uidToSecuence($mbox, $messages); imap_setflag_full($mbox, $messages, '\\Seen'); imap_close($mbox); }
public function deleteMessage($id) { $status = imap_setflag_full($this->mailbox, $id, '\\Deleted'); imap_expunge($this->mailbox); header("Location: /"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ return $status; }
function skip_mail($imap, $current_message, $note, $mail = false) { // display note, and clear process lock. global $lang, $applicationname, $email_errors, $imap, $current_message, $email_errors_address, $email_from; echo $note . "\r\n"; if ($current_message != "") { imap_setflag_full($imap, "{$current_message}", "\\Seen \\Flagged"); echo "Marked message as seen. It will be omitted on the next run.\r\n\r\n"; } if ($mail && $email_errors) { send_mail($email_errors_address, $applicationname . " - " . $lang["checkmail_mail_skipped"], $note, $email_from); } clear_process_lock("checkmail"); die; }
/** * @param string $search */ public static function search($search = 'UNSEEN') { $data = imap_search(self::$mbox, $search); $messages = array(); if ($data !== false) { foreach ($data as $i) { $headerArr = imap_headerinfo(self::$mbox, $i); self::getMsg($i); $messages[] = array('from' => $headerArr->sender[0]->mailbox . "@" . $headerArr->sender[0]->host, 'to' => $headerArr->to[0]->mailbox . "@" . $headerArr->to[0]->host, 'date' => $headerArr->date, 'size' => $headerArr->Size, 'charset' => self::$charset, 'name' => self::decode($headerArr->sender[0]->personal), 'subject' => self::decode($headerArr->subject), 'plain' => self::$plainmsg, 'html' => self::$htmlmsg, 'attach' => self::$attachments); imap_setflag_full(self::$mbox, $i, "\\Seen"); } self::$messages = $messages; unset($messages); } }
function purge_message($mailbox, $message) { if (isset($message['imap_uid'])) { if ($result = $this->open_mailbox($mailbox)) { if ($mailbox->settings['delete_after_read']) { imap_delete($result, $message['imap_uid'], FT_UID); } elseif (!isset($mailbox->settings['flag_after_read']) || $mailbox->settings['flag_after_read']) { imap_setflag_full($result, (string) $message['imap_uid'], '\\Seen', FT_UID); } $this->close_mailbox($result); } else { drupal_set_message(t('Unable to connect to mailbox.')); watchdog('mailhandler', 'Unable to connect to %mail', array('%mail' => $mailbox->mail), WATCHDOG_ERROR); } } }
/** * 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") { global $htmlmsg, $plainmsg, $attachments; // If our imap connection failed earlier, return no messages if ($this->imap_stream == false) { return array(); } $no_of_msgs = imap_num_msg($this->imap_stream); $max_imap_messages = Kohana::config('email.max_imap_messages'); // Check to see if the number of messages we want to sort through is greater than // the number of messages we want to allow. If there are too many messages, it // can fail and that's no good. $msg_to_pull = $no_of_msgs; //** Disabled this config setting for now - causing issues ** //if($msg_to_pull > $max_imap_messages){ // $msg_to_pull = $max_imap_messages; //} $messages = array(); for ($msgno = 1; $msgno <= $msg_to_pull; $msgno++) { $header = imap_headerinfo($this->imap_stream, $msgno); if (!isset($header->message_id) or !isset($header->udate)) { continue; } $message_id = $header->message_id; $date = date($date_format, $header->udate); if (isset($header->from)) { $from = $header->from; } else { $from = FALSE; } $fromname = ""; $fromaddress = ""; $subject = ""; $body = ""; $attachments = ""; if ($from != FALSE) { foreach ($from as $id => $object) { if (isset($object->personal)) { $fromname = $object->personal; } if (isset($object->mailbox) and isset($object->host)) { $fromaddress = $object->mailbox . "@" . $object->host; } if ($fromname == "") { // In case from object doesn't have Name $fromname = $fromaddress; } } } if (isset($header->subject)) { $subject = $this->_mime_decode($header->subject); } // Fetch Body $this->_getmsg($this->imap_stream, $msgno); if ($htmlmsg) { // Convert HTML to Text $html2text = new Html2Text($htmlmsg); $htmlmsg = $html2text->get_text(); } $body = $plainmsg ? $plainmsg : $htmlmsg; // Fetch Attachments $attachments = $this->_extract_attachments($this->imap_stream, $msgno); // Convert to valid UTF8 $body = htmlentities($body); $subject = htmlentities(strip_tags($subject)); array_push($messages, array('message_id' => $message_id, 'date' => $date, 'from' => $fromname, 'email' => $fromaddress, 'subject' => $subject, 'body' => $body, 'attachments' => $attachments)); // Mark Message As Read imap_setflag_full($this->imap_stream, $msgno, "\\Seen"); } return $messages; }
/** * get the basic details like sender and reciver with flags like attatchments etc * * @param int $uid the number of the message * @return array empty on error/nothing or array of formatted details */ protected function _getFormattedMail($Model, $uid, $fetchAttachments = false) { // Translate uid to msg_no. Has no decent fail $msg_number = imap_msgno($this->Stream, $uid); // A hack to detect if imap_msgno failed, and we're in fact looking at the wrong mail if ($uid != ($mailuid = imap_uid($this->Stream, $msg_number))) { pr(compact('Mail')); return $this->err($Model, 'Mail id mismatch. parameter id: %s vs mail id: %s', $uid, $mailuid); } // Get Mail with a property: 'date' or fail if (!($Mail = imap_headerinfo($this->Stream, $msg_number)) || !property_exists($Mail, 'date')) { pr(compact('Mail')); return $this->err($Model, 'Unable to find mail date property in Mail corresponding with uid: %s. Something must be wrong', $uid); } // Get Mail with a property: 'type' or fail if (!($flatStructure = $this->_flatStructure($Model, $uid))) { return $this->err($Model, 'Unable to find structure type property in Mail corresponding with uid: %s. Something must be wrong', $uid); } $plain = $this->_fetchFirstByMime($flatStructure, 'text/plain'); $html = $this->_fetchFirstByMime($flatStructure, 'text/html'); $return[$Model->alias] = array('id' => $this->_toId($uid), 'message_id' => $Mail->message_id, 'email_number' => $Mail->Msgno, 'to' => $this->_personId($Mail, 'to', 'address'), 'to_name' => $this->_personId($Mail, 'to', 'name'), 'from' => $this->_personId($Mail, 'from', 'address'), 'from_name' => $this->_personId($Mail, 'from', 'name'), 'reply_to' => $this->_personId($Mail, 'reply_to', 'address'), 'reply_to_name' => $this->_personId($Mail, 'reply_to', 'name'), 'sender' => $this->_personId($Mail, 'sender', 'address'), 'sender_name' => $this->_personId($Mail, 'sender', 'name'), 'subject' => htmlspecialchars(@$Mail->subject), 'slug' => Inflector::slug(@$Mail->subject, '-'), 'header' => @imap_fetchheader($this->Stream, $uid, FT_UID), 'body' => $html, 'plainmsg' => $plain ? $plain : $html, 'size' => @$Mail->Size, 'recent' => @$Mail->Recent === 'R' ? 1 : 0, 'seen' => @$Mail->Unseen === 'U' ? 0 : 1, 'flagged' => @$Mail->Flagged === 'F' ? 1 : 0, 'answered' => @$Mail->Answered === 'A' ? 1 : 0, 'draft' => @$Mail->Draft === 'X' ? 1 : 0, 'deleted' => @$Mail->Deleted === 'D' ? 1 : 0, 'thread_count' => $this->_getThreadCount($Mail), 'in_reply_to' => @$Mail->in_reply_to, 'reference' => @$Mail->references, 'new' => (int) @$Mail->in_reply_to, 'created' => date('Y-m-d H:i:s', strtotime($Mail->date))); if ($fetchAttachments) { $return['Attachment'] = $this->_fetchAttachments($flatStructure, $Model); } // Auto mark after read if (!empty($this->config['auto_mark_as'])) { $marks = '\\' . join(' \\', $this->config['auto_mark_as']); if (!imap_setflag_full($this->Stream, $uid, $marks, ST_UID)) { $this->err($Model, 'Unable to mark email %s as %s', $uid, $marks); } } return $return; }
function fetchEmails() { if (!$this->connect()) { return false; } $archiveFolder = $this->getArchiveFolder(); $delete = $this->canDeleteEmails(); $max = $this->getMaxFetch(); $nummsgs = imap_num_msg($this->mbox); //echo "New Emails: $nummsgs\n"; $msgs = $errors = 0; for ($i = $nummsgs; $i > 0; $i--) { //process messages in reverse. if ($this->createTicket($i)) { imap_setflag_full($this->mbox, imap_uid($this->mbox, $i), "\\Seen", ST_UID); //IMAP only?? if ((!$archiveFolder || !imap_mail_move($this->mbox, $i, $archiveFolder)) && $delete) { imap_delete($this->mbox, $i); } $msgs++; $errors = 0; //We are only interested in consecutive errors. } else { $errors++; } if ($max && ($msgs >= $max || $errors > $max * 0.8)) { break; } } //Warn on excessive errors if ($errors > $msgs) { $warn = sprintf(_S('Excessive errors processing emails for %1$s/%2$s. Please manually check the inbox.'), $this->getHost(), $this->getUsername()); $this->log($warn); } @imap_expunge($this->mbox); return $msgs; }
/** * Set flags */ function email_setflag(){ imap_setflag_full($this->link, "2,5","\\Seen \\Flagged"); }
<?php // read mails from internal bounce mailbox and set invalidEmail=1 for these email addresses require '/var/www/yoursite/http/variables.php'; require '/var/www/yoursite/http/variablesdb.php'; require_once '/var/www/yoursite/http/functions.php'; require '/var/www/yoursite/http/log/KLogger.php'; $log = new KLogger('/var/www/yoursite/http/log/bounces/', KLogger::INFO); $mailbox = imap_open('{localhost:993/ssl/novalidate-cert}', 'bounce', 'bounce01$'); $mailbox_info = imap_check($mailbox); for ($i = 1; $i <= $mailbox_info->Nmsgs; $i++) { $msg = imap_fetch_overview($mailbox, $i); $rcpt = $msg[0]->to; if (substr($rcpt, 0, 6) == 'bounce') { $target = substr($rcpt, 7); // exclude 'bounce=' $target = substr($target, 0, -9); // exclude '@yoursite' $target = str_replace('=', '@', $target); // revert '=' to '@' if ($msg[0]->answered == 0) { $sql = "UPDATE {$playerstable} SET invalidEmail=1 WHERE invalidEmail=0 AND mail='" . $target . "'"; mysql_query($sql); $affected = mysql_affected_rows(); $uid = imap_uid($mailbox, $i); $status = imap_setflag_full($mailbox, $uid, '\\Answered \\Seen', ST_UID); $log->logInfo('sql=[' . $sql . '] affected=[' . $affected . '] status=[' . $status . ']'); } } } imap_close($mailbox); // close the mailbox
$mimetype = $type[(int) $info->parts[$counter]->type] . '/' . $info->parts[$counter]->subtype; $mimetype = strtolower($mimetype); echo " - File: {$filename} ({$mimetype})... "; $fullfilename = 'tmp/attachments/' . $uid . '/' . $filename; $file = 'tmp/attachments/' . $uid . '/mail.txt'; imap_savebody($inbox, $file, $message->msgno); $parser = new MimeMailParser(); $parser->setPath($file); $attachments = $parser->getAttachmentsAsStreams(); file_put_contents($fullfilename, $attachments[$counter - 1]); echo "done\n"; $package->addFile($filename, $mimetype); $counter++; } // Deposit the package $package->create(); $client = new SWORDAPPClient(); $response = $client->deposit($swordurl, $sworduser, $swordpassword, '', 'tmp/' . $packagefilename, 'http://purl.org/net/sword-types/METSDSpaceSIP', 'application/zip', false, true); // print_r($response); $id = $response->sac_id; $id = str_replace("http://hdl.handle.net/", "http://dspace.swordapp.org/jspui/handle/", $id); echo "Deposited at " . $id . "\n\n"; $to = $message->from; $from = "From: " . $mailuser; $subject = "Deposit successful: " . $id; $contents = "Thanks you for your deposit. It can be viewed at " . $id; mail($to, $subject, $contents, $from); // Mark the message as read imap_setflag_full($inbox, $message->msgno, "\\Seen"); } }
/** * Called when the user moves an item on the PDA from one folder to another * * @param string $folderid id of the source folder * @param string $id id of the message * @param string $newfolderid id of the destination folder * @param ContentParameters $contentparameters * * @access public * @return boolean status of the operation * @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions */ public function MoveMessage($folderid, $id, $newfolderid, $contentparameters) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s')", $folderid, $id, $newfolderid)); $folderImapid = $this->getImapIdFromFolderId($folderid); $newfolderImapid = $this->getImapIdFromFolderId($newfolderid); if ($folderImapid == $newfolderImapid) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, destination folder is source folder. Canceling the move.", $folderid, $id, $newfolderid), SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST); } $this->imap_reopen_folder($folderImapid); if ($this->imap_inside_cutoffdate(Utils::GetCutOffDate($contentparameters->GetFilterType()), $id)) { // read message flags $overview = @imap_fetch_overview($this->mbox, $id, FT_UID); if (!is_array($overview)) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to retrieve overview of source message: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID); } else { // get next UID for destination folder // when moving a message we have to announce through ActiveSync the new messageID in the // destination folder. This is a "guessing" mechanism as IMAP does not inform that value. // when lots of simultaneous operations happen in the destination folder this could fail. // in the worst case the moved message is displayed twice on the mobile. $destStatus = imap_status($this->mbox, $this->server . $newfolderImapid, SA_ALL); if (!$destStatus) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to open destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDDESTID); } $newid = $destStatus->uidnext; // move message $s1 = imap_mail_move($this->mbox, $id, $newfolderImapid, CP_UID); if (!$s1) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, copy to destination folder failed: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE); } // delete message in from-folder $s2 = imap_expunge($this->mbox); // open new folder $stat = $this->imap_reopen_folder($newfolderImapid); if (!$stat) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, opening the destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE); } // remove all flags $s3 = @imap_clearflag_full($this->mbox, $newid, "\\Seen \\Answered \\Flagged \\Deleted \\Draft", FT_UID); $newflags = ""; $move_to_trash = strcasecmp($newfolderImapid, $this->create_name_folder(IMAP_FOLDER_TRASH)) == 0; if ($overview[0]->seen || $move_to_trash && defined('IMAP_AUTOSEEN_ON_DELETE') && IMAP_AUTOSEEN_ON_DELETE == true) { $newflags .= "\\Seen"; } if ($overview[0]->flagged) { $newflags .= " \\Flagged"; } if ($overview[0]->answered) { $newflags .= " \\Answered"; } $s4 = @imap_setflag_full($this->mbox, $newid, $newflags, FT_UID); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): result s-move: '%s' s-expunge: '%s' unset-Flags: '%s' set-Flags: '%s'", $folderid, $id, $newfolderid, Utils::PrintAsString($s1), Utils::PrintAsString($s2), Utils::PrintAsString($s3), Utils::PrintAsString($s4))); // return the new id "as string" return $newid . ""; } } else { throw new StatusException(sprintf("BackendIMAP->MoveMessage(): Message is outside the sync range"), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID); } }
$smarty->assign('SUBJECT', $focus->column_fields['subject']); $smarty->assign('DESCRIPTION', $focus->column_fields['description']); } $smarty->display('PrintEmail.tpl'); } if (isset($_REQUEST['record']) && isset($_REQUEST['mailbox']) && $_REQUEST['print']) { if (isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "") { $mailbox = $_REQUEST["mailbox"]; } else { $mailbox = "INBOX"; } $mailid = $_REQUEST['record']; $MailBox = new MailBox($mailbox); $mail = $MailBox->mbox; $email = new Webmails($MailBox->mbox, $mailid); $status = imap_setflag_full($MailBox->mbox, $mailid, "\\Seen"); $attach_tab = array(); $email->loadMail($attach_tab); echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $email->charsets . "\">\n"; //JFV - for subject garbled issue reported by ayano, if (function_exists("mb_decode_mimeheader") && function_exists("mb_internal_encoding") && function_exists("mb_convert_encoding")) { if (strtoupper(substr($email->subject, 0, 13)) == "=?ISO-2022-JP" && @mb_convert_encoding(1, 'iso-2022-jp-ms')) { $jfv_subject = str_ireplace('?iso-2022-jp?', '?iso-2022-jp-ms?', $email->subject); } elseif (strtoupper(substr($email->subject, 0, 11)) == "=?SHIFT_JIS" && @mb_convert_encoding(1, 'SJIS-win')) { $jfv_subject = str_ireplace('?shift_jis?', '?SJIS-win?', $email->subject); } elseif (strtoupper(substr($email->subject, 0, 8)) == "=?EUC-JP" && @mb_convert_encoding(1, 'eucJP-win')) { $jfv_subject = str_ireplace('?euc-jp?', '?eucJP-win?', $email->subject); } else { $jfv_subject = $email->subject; } $jfv_default_internal_enc = mb_internal_encoding();
/** * Called when the user moves an item on the PDA from one folder to another * * @param string $folderid id of the source folder * @param string $id id of the message * @param string $newfolderid id of the destination folder * @param ContentParameters $contentparameters * * @access public * @return boolean status of the operation * @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions */ public function MoveMessage($folderid, $id, $newfolderid, $contentparameters) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s')", $folderid, $id, $newfolderid)); $folderImapid = $this->getImapIdFromFolderId($folderid); // SDB: When iOS is configured to "Archive Message" (instead of Delete Message), it will send a "MoveItems" // command to the Exchange server and attempt to move it to a folder called "0/Archive". Instead, we trap that // and send it to "[Gmail]/All Mail" folder instead. Note, that when on iOS device and you trigger a move from // folder A to B, it will correctly move that email, including to all folders with "[Gmail]...". if ($newfolderid == "0/Archive") { $newfolderImapid = "[Gmail]/All Mail"; } else { $newfolderImapid = $this->getImapIdFromFolderId($newfolderid); } if ($folderImapid == $newfolderImapid) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, destination folder is source folder. Canceling the move.", $folderid, $id, $newfolderid), SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST); } $this->imap_reopen_folder($folderImapid); if ($this->imap_inside_cutoffdate(Utils::GetCutOffDate($contentparameters->GetFilterType()), $id)) { // read message flags $overview = @imap_fetch_overview($this->mbox, $id, FT_UID); if (!is_array($overview)) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to retrieve overview of source message: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID); } else { // get next UID for destination folder // when moving a message we have to announce through ActiveSync the new messageID in the // destination folder. This is a "guessing" mechanism as IMAP does not inform that value. // when lots of simultaneous operations happen in the destination folder this could fail. // in the worst case the moved message is displayed twice on the mobile. $destStatus = imap_status($this->mbox, $this->server . $newfolderImapid, SA_ALL); if (!$destStatus) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to open destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDDESTID); } $newid = $destStatus->uidnext; // move message $s1 = imap_mail_move($this->mbox, $id, $newfolderImapid, CP_UID); if (!$s1) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, copy to destination folder failed: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE); } // delete message in from-folder $s2 = imap_expunge($this->mbox); // open new folder $stat = $this->imap_reopen_folder($newfolderImapid); if (!$s1) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, opening the destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE); } // remove all flags $s3 = @imap_clearflag_full($this->mbox, $newid, "\\Seen \\Answered \\Flagged \\Deleted \\Draft", FT_UID); $newflags = ""; if ($overview[0]->seen) { $newflags .= "\\Seen"; } if ($overview[0]->flagged) { $newflags .= " \\Flagged"; } if ($overview[0]->answered) { $newflags .= " \\Answered"; } $s4 = @imap_setflag_full($this->mbox, $newid, $newflags, FT_UID); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): result s-move: '%s' s-expunge: '%s' unset-Flags: '%s' set-Flags: '%s'", $folderid, $id, $newfolderid, Utils::PrintAsString($s1), Utils::PrintAsString($s2), Utils::PrintAsString($s3), Utils::PrintAsString($s4))); // return the new id "as string" return $newid . ""; } } else { throw new StatusException(sprintf("BackendIMAP->MoveMessage(): Message is outside the sync range"), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID); } }
protected function flagMailSeen($msgno) { if (!$this->isConnected()) { static::raiseError(__METHOD__ . '(), need to be connected to the mail server to proceed!'); return false; } if (!imap_setflag_full($this->imap_session, $msgno, '\\Seen')) { static::raiseError(__METHOD__ . '(), imap_setflag_full() returned false!' . imap_last_error()); return false; } return true; }
/** * This function is used to enable or disable one or more flags on the imap message. * * @param string|array $flag Flagged, Answered, Deleted, Seen, Draft * @param bool $enable * @throws \InvalidArgumentException * @return bool */ public function setFlag($flag, $enable = true) { $flags = is_array($flag) ? $flag : array($flag); foreach ($flags as $i => $flag) { $flag = ltrim(strtolower($flag), '\\'); if (!in_array($flag, self::$flagTypes) || $flag == self::FLAG_RECENT) { throw new \InvalidArgumentException('Unable to set invalid flag "' . $flag . '"'); } if ($enable) { $this->status[$flag] = true; } else { unset($this->status[$flag]); } $flags[$i] = $flag; } $imapifiedFlag = '\\' . implode(' \\', array_map('ucfirst', $flags)); if ($enable === true) { return imap_setflag_full($this->imapStream, $this->uid, $imapifiedFlag, ST_UID); } else { return imap_clearflag_full($this->imapStream, $this->uid, $imapifiedFlag, ST_UID); } }
/** * Called when the user moves an item on the PDA from one folder to another * * @param string $folderid id of the source folder * @param string $id id of the message * @param string $newfolderid id of the destination folder * * @access public * @return boolean status of the operation * @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions */ public function MoveMessage($folderid, $id, $newfolderid) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s')", $folderid, $id, $newfolderid)); $folderImapid = $this->getImapIdFromFolderId($folderid); $newfolderImapid = $this->getImapIdFromFolderId($newfolderid); $this->imap_reopenFolder($folderImapid); // TODO this should throw a StatusExceptions on errors like SYNC_MOVEITEMSSTATUS_SAMESOURCEANDDEST,SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID,SYNC_MOVEITEMSSTATUS_CANNOTMOVE // read message flags $overview = @imap_fetch_overview($this->mbox, $id, FT_UID); if (!$overview) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to retrieve overview of source message: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID); } else { // get next UID for destination folder // when moving a message we have to announce through ActiveSync the new messageID in the // destination folder. This is a "guessing" mechanism as IMAP does not inform that value. // when lots of simultaneous operations happen in the destination folder this could fail. // in the worst case the moved message is displayed twice on the mobile. $destStatus = imap_status($this->mbox, $this->server . $newfolderImapid, SA_ALL); if (!$destStatus) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, unable to open destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_INVALIDDESTID); } $newid = $destStatus->uidnext; // move message $s1 = imap_mail_move($this->mbox, $id, $newfolderImapid, CP_UID); if (!$s1) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, copy to destination folder failed: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE); } // delete message in from-folder $s2 = imap_expunge($this->mbox); // open new folder $stat = $this->imap_reopenFolder($newfolderImapid); if (!$s1) { throw new StatusException(sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): Error, openeing the destination folder: %s", $folderid, $id, $newfolderid, imap_last_error()), SYNC_MOVEITEMSSTATUS_CANNOTMOVE); } // remove all flags $s3 = @imap_clearflag_full($this->mbox, $newid, "\\Seen \\Answered \\Flagged \\Deleted \\Draft", FT_UID); $newflags = ""; if ($overview[0]->seen) { $newflags .= "\\Seen"; } if ($overview[0]->flagged) { $newflags .= " \\Flagged"; } if ($overview[0]->answered) { $newflags .= " \\Answered"; } $s4 = @imap_setflag_full($this->mbox, $newid, $newflags, FT_UID); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s'): result s-move: '%s' s-expunge: '%s' unset-Flags: '%s' set-Flags: '%s'", $folderid, $id, $newfolderid, Utils::PrintAsString($s1), Utils::PrintAsString($s2), Utils::PrintAsString($s3), Utils::PrintAsString($s4))); // return the new id "as string"" return $newid . ""; } }
/** * setzt ein Flag bei allen in $sequence aufgeführten Messages * @param string $sequence * @param string $flag * @param integer $options * @return boolean */ public function imapSetflagFull($sequence, $flag, $options = 0) { if ($this->imap === null) { throw new IMAPException(__METHOD__ . ' not connected'); } $this->imapPing(true); return imap_setflag_full($this->imap, $sequence, $flag, $options); }
} elseif ($_POST['defer']) { // do not mark as read, but skip it } elseif ($_POST['ignore']) { // ignore //mark as read THIS IS NOT working with POP3 Grrrr! $status = imap_setflag_full($mbox, $_SESSION['unread_list'][$_SESSION['curr_index']], "\\Seen"); } elseif ($_POST['reply']) { // send the message $header = imap_header($mbox, $_SESSION['unread_list'][$_SESSION['curr_index']]); $to = $header->reply_toaddress; $subject = $header->subject; // send the message imap_mail($to, $subject, $_POST['message']); //echo imap_last_error(); // mark it as read $status = imap_setflag_full($mbox, $_SESSION['unread_list'][$_SESSION['curr_index']], "\\Seen"); } $_SESSION['curr_index'] = $_SESSION['curr_index'] + 1; // get next message if ($_SESSION['curr_index'] == count($_SESSION['unread_list'])) { // we have reached the end of the list of unread messages. What do to now? echo '<div class="message">end of triage!</div>'; $temp = count(imap_search($mbox, 'UNSEEN')); if (imap_search($mbox, 'UNSEEN')) { echo '<div>There ' . pluralize('is', $temp) . ' ' . $temp . ' messages still un-read</div>'; echo '<div>You you wish to QUIT or Triage the remaining ' . pluralize('message', $temp) . '?</div>'; } renderLogout($device, $lang); // re-triage the defered messages? // quit? } else {
/** * This function is used to enable or disable a flag on the imap message. * * @param string $flag Flagged, Answered, Deleted, Seen, Draft * @param bool $enable * @return bool */ public function setFlag($flag, $enable = true) { if (!in_array($flag, self::$flagTypes) || $flag == 'recent') { throw new \InvalidArgumentException('Unable to set invalid flag "' . $flag . '"'); } $flag = '\\' . ucfirst($flag); if ($enable) { return imap_setflag_full($this->imapStream, $this->uid, $flag, ST_UID); } else { return imap_clearflag_full($this->imapStream, $this->uid, $flag, ST_UID); } }
/** * Marks the mail as Read * @param String $msgno - Message Number */ function markMailRead($msgno) { imap_setflag_full($this->mBox, $msgno, '\\Seen'); $this->mModified = true; }
function flagMessages($flag, $aMessagesUID) { if (empty($aMessagesUID)) { return false; } reset($aMessagesUID); $msglist = ''; while (list($key, $value) = each($aMessagesUID)) { if (!empty($msglist)) { $msglist .= ","; } $msglist .= $value; } switch ($flag) { case "flagged": $result = imap_setflag_full($this->stream(), $msglist, "\\Flagged", ST_UID); break; case "read": $result = imap_setflag_full($this->stream(), $msglist, "\\Seen", ST_UID); break; case "answered": $result = imap_setflag_full($this->stream(), $msglist, "\\Answered", ST_UID); break; case "unflagged": $result = imap_clearflag_full($this->stream(), $msglist, "\\Flagged", ST_UID); break; case "unread": $result = imap_clearflag_full($this->stream(), $msglist, "\\Seen", ST_UID); $result = imap_clearflag_full($this->stream(), $msglist, "\\Answered", ST_UID); break; } return $result; }
/** * Mark the message in the mailbox. */ function markMessage($messageid) { $markas = $this->_scannerinfo->markas; if ($this->_imap && $markas) { if (strtoupper($markas) == 'SEEN') { $markas = "\\Seen"; } imap_setflag_full($this->_imap, $messageid, $markas); } }
/** * Causes a store to add the specified flag to the flags set for the mails in the specified sequence. * * @param array $mailsIds * @param string $flag which you can set are \Seen, \Answered, \Flagged, \Deleted, and \Draft as defined by RFC2060. * @return bool */ public function setFlag(array $mailsIds, $flag) { return imap_setflag_full($this->getImapStream(), implode(',', $mailsIds), $flag, ST_UID); }
/** * put the message from unread to read * * @param string $msg_count * @return bool */ public function mail_read($msg_count) { $status = imap_setflag_full($this->_connect, $msg_count, "//Seen"); return $status; }
$ih = @imap_open("{" . ConfigHelper::getConfig('cashimport.server') . "}INBOX", ConfigHelper::getConfig('cashimport.username'), ConfigHelper::getConfig('cashimport.password')); if (!$ih) { die("Cannot connect to mail server!" . PHP_EOL); } $posts = imap_search($ih, ConfigHelper::checkValue(ConfigHelper::getConfig('cashimport.use_seen_flag', true)) ? 'UNSEEN' : 'ALL'); if (!empty($posts)) { foreach ($posts as $postid) { $post = imap_fetchstructure($ih, $postid); if ($post->type == 1) { $parts = $post->parts; //print_r($parts); foreach ($parts as $partid => $part) { if ($part->ifdisposition && strtoupper($part->disposition) == 'ATTACHMENT' && $part->type == 0) { $fname = $part->dparameters[0]->value; $msg = imap_fetchbody($ih, $postid, $partid + 1); if ($part->encoding == 3) { $msg = imap_base64($msg); } if (ConfigHelper::checkValue(ConfigHelper::getConfig('cashimport.use_seen_flag', true))) { imap_setflag_full($ih, $postid, "\\Seen"); } parse_file($fname, $msg); if (ConfigHelper::checkValue(ConfigHelper::getConfig('cashimport.autocommit', false))) { commit_cashimport(); } } } } } } imap_close($ih);
function mailcwp_delete_callback() { $result = array(); $mailcwp_session = mailcwp_get_session(); if (!isset($mailcwp_session) || empty($mailcwp_session)) { return; } $account = $mailcwp_session["account"]; $use_ssl = $account["use_ssl"]; //$from = $account["email"]; $folder = $mailcwp_session["folder"]; $use_tls = $account["use_tls"]; $messages = $_POST["messages"]; //write_log($messages); //write_log("DELETE MAIL " . print_r($account, true)); $use_ssl_flag = $use_ssl === "true" ? "/ssl" : ""; $use_tls_flag = $use_tls === "true" ? "/tls" : ""; $mbox = mailcwp_imap_connect($account, 0, $folder); //write_log("SEND ACCOUNT " . print_r($account)); $sent_folder = ""; if (is_array($account)) { $trash_folder = $account["trash_folder"]; if (empty($trash_folder)) { $trash_folder = mailcwp_find_folder($mbox, $account, "Trash"); if (empty($trash_folder)) { $trash_folder = mailcwp_find_folder($mbox, $account, "Deleted"); } } if (!empty($trash_folder) && $trash_folder != $folder) { //write_log("DELETE MOVE MESSAGES " . print_r($messages, true)); imap_mail_move($mbox, $messages, $trash_folder); imap_expunge($mbox); $result["result"] = "OK"; $result["message"] = "Moved to {$trash_folder}"; $result["imap_errors"] = imap_errors(); } else { imap_setflag_full($mbox, $messages, "\\Deleted"); $result["result"] = "OK"; if (!empty($trash_folder) && $folder == $trash_folder) { imap_expunge($mbox); $result["message"] = "Permanently Deleted"; } else { $result["message"] = "Marked as Deleted"; } $result["imap_errors"] = imap_errors(); } } else { $result["result"] = "Failed"; $result["message"] = "Account not found."; } //write_log("DELETE MESSAGES ($messages) " . print_r(imap_errors(), true)); echo json_encode($result); die; }
function MoveMessage($folderid, $id, $newfolderid) { debugLog("IMAP-MoveMessage: (sfid: '{$folderid}' id: '{$id}' dfid: '{$newfolderid}' )"); $this->imap_reopenFolder($folderid); // read message flags $overview = @imap_fetch_overview($this->_mbox, $id, FT_UID); if (!$overview) { debugLog("IMAP-MoveMessage: Failed to retrieve overview"); return false; } else { // move message $s1 = imap_mail_move($this->_mbox, $id, str_replace(".", $this->_serverdelimiter, $newfolderid), FT_UID); // delete message in from-folder $s2 = imap_expunge($this->_mbox); // open new folder $this->imap_reopenFolder($newfolderid); // remove all flags $s3 = @imap_clearflag_full($this->_mbox, $id, "\\Seen \\Answered \\Flagged \\Deleted \\Draft", FT_UID); $newflags = ""; if ($overview[0]->seen) { $newflags .= "\\Seen"; } if ($overview[0]->flagged) { $newflags .= " \\Flagged"; } if ($overview[0]->answered) { $newflags .= " \\Answered"; } $s4 = @imap_setflag_full($this->_mbox, $id, $newflags, FT_UID); debugLog("MoveMessage: (" . $folderid . "->" . $newfolderid . ") s-move: {$s1} s-expunge: {$s2} unset-Flags: {$s3} set-Flags: {$s4}"); return $s1 && $s2 && $s3 && $s4; } }
/** * shiny new importOneEmail() method * @param int msgNo * @param bool forDisplay * @param clean_email boolean, default true, */ function importOneEmail($msgNo, $uid, $forDisplay = false, $clean_email = true) { $GLOBALS['log']->debug("InboundEmail processing 1 email {$msgNo}-----------------------------------------------------------------------------------------"); global $timedate; global $app_strings; global $app_list_strings; global $sugar_config; global $current_user; // Bug # 45477 // So, on older versions of PHP (PHP VERSION < 5.3), // calling imap_headerinfo and imap_fetchheader can cause a buffer overflow for exteremly large headers, // This leads to the remaining messages not being read because Sugar crashes everytime it tries to read the headers. // The workaround is to mark a message as read before making trying to read the header of the msg in question // This forces this message not be read again, and we can continue processing remaining msgs. // UNCOMMENT THIS IF YOU HAVE THIS PROBLEM! See notes on Bug # 45477 // $this->markEmails($uid, "read"); $header = imap_headerinfo($this->conn, $msgNo); $fullHeader = imap_fetchheader($this->conn, $msgNo); // raw headers // reset inline images cache $this->inlineImages = array(); // handle messages deleted on server if (empty($header)) { if (!isset($this->email) || empty($this->email)) { $this->email = new Email(); } $q = ""; if ($this->isPop3Protocol()) { $this->email->name = $app_strings['LBL_EMAIL_ERROR_MESSAGE_DELETED']; $q = "DELETE FROM email_cache WHERE message_id = '{$uid}' AND ie_id = '{$this->id}' AND mbox = '{$this->mailbox}'"; } else { $this->email->name = $app_strings['LBL_EMAIL_ERROR_IMAP_MESSAGE_DELETED']; $q = "DELETE FROM email_cache WHERE imap_uid = {$uid} AND ie_id = '{$this->id}' AND mbox = '{$this->mailbox}'"; } // else // delete local cache $r = $this->db->query($q); $this->email->date_sent = $timedate->nowDb(); return false; //return "Message deleted from server."; } /////////////////////////////////////////////////////////////////////// //// DUPLICATE CHECK $dupeCheckResult = $this->importDupeCheck($header->message_id, $header, $fullHeader); if ($forDisplay || $dupeCheckResult) { $GLOBALS['log']->debug('*********** NO duplicate found, continuing with processing.'); $structure = imap_fetchstructure($this->conn, $msgNo); // map of email /////////////////////////////////////////////////////////////////// //// CREATE SEED EMAIL OBJECT $email = new Email(); $email->isDuplicate = $dupeCheckResult ? false : true; $email->mailbox_id = $this->id; $message = array(); $email->id = create_guid(); $email->new_with_id = true; //forcing a GUID here to prevent double saves. //// END CREATE SEED EMAIL /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// //// PREP SYSTEM USER if (empty($current_user)) { // I-E runs as admin, get admin prefs $current_user = new User(); $current_user->getSystemUser(); } $tPref = $current_user->getUserDateTimePreferences(); //// END USER PREP /////////////////////////////////////////////////////////////////// if (!empty($header->date)) { $unixHeaderDate = $timedate->fromString($header->date); } /////////////////////////////////////////////////////////////////// //// HANDLE EMAIL ATTACHEMENTS OR HTML TEXT //// Inline images require that I-E handle attachments before body text // parts defines attachments - be mindful of .html being interpreted as an attachment if ($structure->type == 1 && !empty($structure->parts)) { $GLOBALS['log']->debug('InboundEmail found multipart email - saving attachments if found.'); $this->saveAttachments($msgNo, $structure->parts, $email->id, 0, $forDisplay); } elseif ($structure->type == 0) { $uuemail = $this->isUuencode($email->description) ? true : false; /* * UUEncoded attachments - legacy, but still have to deal with it * format: * begin 777 filename.txt * UUENCODE * * end */ // set body to the filtered one if ($uuemail) { $email->description = $this->handleUUEncodedEmailBody($email->description, $email->id); $email->retrieve($email->id); $email->save(); } } else { if ($this->port != 110) { $GLOBALS['log']->debug('InboundEmail found a multi-part email (id:' . $msgNo . ') with no child parts to parse.'); } } //// END HANDLE EMAIL ATTACHEMENTS OR HTML TEXT /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// //// ASSIGN APPROPRIATE ATTRIBUTES TO NEW EMAIL OBJECT // handle UTF-8/charset encoding in the ***headers*** global $db; $email->name = $this->handleMimeHeaderDecode($header->subject); $email->date_start = !empty($unixHeaderDate) ? $timedate->asUserDate($unixHeaderDate) : ""; $email->time_start = !empty($unixHeaderDate) ? $timedate->asUserTime($unixHeaderDate) : ""; $email->type = 'inbound'; $email->date_created = !empty($unixHeaderDate) ? $timedate->asUser($unixHeaderDate) : ""; $email->status = 'unread'; // this is used in Contacts' Emails SubPanel if (!empty($header->toaddress)) { $email->to_name = $this->handleMimeHeaderDecode($header->toaddress); $email->to_addrs_names = $email->to_name; } if (!empty($header->to)) { $email->to_addrs = $this->convertImapToSugarEmailAddress($header->to); } $email->from_name = $this->handleMimeHeaderDecode($header->fromaddress); $email->from_addr_name = $email->from_name; $email->from_addr = $this->convertImapToSugarEmailAddress($header->from); if (!empty($header->cc)) { $email->cc_addrs = $this->convertImapToSugarEmailAddress($header->cc); } if (!empty($header->ccaddress)) { $email->cc_addrs_names = $this->handleMimeHeaderDecode($header->ccaddress); } // if $email->reply_to_name = $this->handleMimeHeaderDecode($header->reply_toaddress); $email->reply_to_email = $this->convertImapToSugarEmailAddress($header->reply_to); if (!empty($email->reply_to_email)) { $email->reply_to_addr = $email->reply_to_name; } $email->intent = $this->mailbox_type; $email->message_id = $this->compoundMessageId; // filled by importDupeCheck(); $oldPrefix = $this->imagePrefix; if (!$forDisplay) { // Store CIDs in imported messages, convert on display $this->imagePrefix = "cid:"; } // handle multi-part email bodies $email->description_html = $this->getMessageText($msgNo, 'HTML', $structure, $fullHeader, $clean_email); // runs through handleTranserEncoding() already $email->description = $this->getMessageText($msgNo, 'PLAIN', $structure, $fullHeader, $clean_email); // runs through handleTranserEncoding() already $this->imagePrefix = $oldPrefix; // empty() check for body content if (empty($email->description)) { $GLOBALS['log']->debug('InboundEmail Message (id:' . $email->message_id . ') has no body'); } // assign_to group if (!empty($_REQUEST['user_id'])) { $email->assigned_user_id = $_REQUEST['user_id']; } else { // Samir Gandhi : Commented out this code as its not needed //$email->assigned_user_id = $this->group_id; } //Assign Parent Values if set if (!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type'])) { $email->parent_id = $_REQUEST['parent_id']; $email->parent_type = $_REQUEST['parent_type']; $mod = strtolower($email->parent_type); $rel = array_key_exists($mod, $email->field_defs) ? $mod : $mod . "_activities_emails"; //Custom modules rel name if (!$email->load_relationship($rel)) { return FALSE; } $email->{$rel}->add($email->parent_id); } // override $forDisplay w/user pref if ($forDisplay) { if ($this->isAutoImport()) { $forDisplay = false; // triggers save of imported email } } if (!$forDisplay) { $email->save(); $email->new_with_id = false; // to allow future saves by UPDATE, instead of INSERT //// ASSIGN APPROPRIATE ATTRIBUTES TO NEW EMAIL OBJECT /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// //// LINK APPROPRIATE BEANS TO NEWLY SAVED EMAIL //$contactAddr = $this->handleLinking($email); //// END LINK APPROPRIATE BEANS TO NEWLY SAVED EMAIL /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// //// MAILBOX TYPE HANDLING $this->handleMailboxType($email, $header); //// END MAILBOX TYPE HANDLING /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// //// SEND AUTORESPONSE if (!empty($email->reply_to_email)) { $contactAddr = $email->reply_to_email; } else { $contactAddr = $email->from_addr; } if (!$this->isMailBoxTypeCreateCase()) { $this->handleAutoresponse($email, $contactAddr); } //// END SEND AUTORESPONSE /////////////////////////////////////////////////////////////////// //// END IMPORT ONE EMAIL /////////////////////////////////////////////////////////////////// } } else { // only log if not POP3; pop3 iterates through ALL mail if ($this->protocol != 'pop3') { $GLOBALS['log']->info("InboundEmail found a duplicate email: " . $header->message_id); //echo "This email has already been imported"; } return false; } //// END DUPLICATE CHECK /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// DEAL WITH THE MAILBOX if (!$forDisplay) { imap_setflag_full($this->conn, $msgNo, '\\SEEN'); // if delete_seen, mark msg as deleted if ($this->delete_seen == 1 && !$forDisplay) { $GLOBALS['log']->info("INBOUNDEMAIL: delete_seen == 1 - deleting email"); imap_setflag_full($this->conn, $msgNo, '\\DELETED'); } } else { // for display - don't touch server files? //imap_setflag_full($this->conn, $msgNo, '\\UNSEEN'); } $GLOBALS['log']->debug('********************************* InboundEmail finished import of 1 email: ' . $email->name); //// END DEAL WITH THE MAILBOX /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// TO SUPPORT EMAIL 2.0 $this->email = $email; if (empty($this->email->et)) { $this->email->email2init(); } return true; }