本文整理汇总了PHP中imap_num_msg函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_num_msg函数的具体用法?PHP imap_num_msg怎么用?PHP imap_num_msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_num_msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getdata
function getdata($host, $login, $password, $savedirpath)
{
$mbox = imap_open($host, $login, $password) or die("can't connect: " . imap_last_error());
$message = array();
$message["attachment"]["type"][0] = "text";
$message["attachment"]["type"][1] = "multipart";
$message["attachment"]["type"][2] = "message";
$message["attachment"]["type"][3] = "application";
$message["attachment"]["type"][4] = "audio";
$message["attachment"]["type"][5] = "image";
$message["attachment"]["type"][6] = "video";
$message["attachment"]["type"][7] = "other";
$buzon_destino = "cfdi";
echo imap_createmailbox($mbox, imap_utf7_encode("{$buzon_destino}"));
echo imap_num_msg($mbox);
for ($jk = 1; $jk <= imap_num_msg($mbox); $jk++) {
$structure = imap_fetchstructure($mbox, $jk);
$parts = $structure->parts;
$fpos = 2;
for ($i = 1; $i < count($parts); $i++) {
$message["pid"][$i] = $i;
$part = $parts[$i];
if (strtolower($part->disposition) == "attachment") {
$message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
$message["subtype"][$i] = strtolower($part->subtype);
$ext = $part->subtype;
$params = $part->dparameters;
$filename = $part->dparameters[0]->value;
if (!($ext == 'xml' or $ext == 'XML' or $ext == 'PDF' or $ext == 'pdf')) {
continue;
}
$mege = "";
$data = "";
$mege = imap_fetchbody($mbox, $jk, $fpos);
$data = $this->getdecodevalue($mege, $part->type);
$fp = fopen($filename, 'w');
fputs($fp, $data);
fclose($fp);
$fpos += 1;
/* Se mueve el archiv descargado al directorio de recibidos */
// rename($filename, $savedirpath.$filename);
// printf("\nSe movio el archivo $filename");
}
}
$result = imap_fetch_overview($mbox, $jk);
echo $result[0]->from;
// imap_mail_move($mbox, $jk, $buzon_destino);
//imap_delete tags a message for deletion
// imap_delete($mbox,$jk);
}
// imap_expunge deletes all tagged messages
// imap_expunge($mbox);
imap_close($mbox);
}
示例2: inbox
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 "hotelpartners@goibibo.com" 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";
}
示例3: inbox
function inbox()
{
$this->msg_cnt = imap_num_msg($this->conn);
$in = array();
for ($i = 1; $i <= 20; $i++) {
$in[] = array('index' => $i, 'header' => imap_headerinfo($this->conn, $i), 'body' => imap_body($this->conn, $i), 'structure' => imap_fetchstructure($this->conn, $i));
}
$this->inbox = $in;
}
示例4: get_messages
/**
* 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_num_msg($this->imap_stream);
$no_of_msgs = imap_num_msg($this->imap_stream);
$messages = array();
for ($i = 1; $i <= $no_of_msgs; $i++) {
$header = imap_headerinfo($this->imap_stream, $i);
$message_id = $header->message_id;
$date = date($date_format, $header->udate);
if (isset($header->from)) {
$from = $header->from;
} else {
$from = FALSE;
}
$fromname = "";
$fromaddress = "";
$subject = "";
if ($from != FALSE) {
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);
}
// Read the message structure
$structure = imap_fetchstructure($this->imap_stream, $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, $i, $j + 1);
}
}
} else {
$body = imap_body($this->imap_stream, $i);
}
// Convert quoted-printable strings (RFC2045)
$body = imap_qprint($body);
// Convert to valid UTF8
$body = htmlentities($body);
$subject = htmlentities($subject);
array_push($messages, array('message_id' => $message_id, 'date' => $date, 'from' => $fromname, 'email' => $fromaddress, 'subject' => $subject, 'body' => $body));
// Mark Message As Read
imap_setflag_full($this->imap_stream, $i, "\\Seen");
}
return $messages;
}
示例5: pop3_body
function pop3_body()
{
$imap = imap_open("{pop.163.com:110/pop3/notls}", "rong360credit01", "rong36000");
$message_count = imap_num_msg($imap);
for ($i = 1; $i <= $message_count; ++$i) {
$header = imap_header($imap, $i);
$date = $header->date;
echo "************msg no: {$i} \n {$date} \n";
$structure = imap_fetchstructure($imap, $i);
// print_r($structure) ;
}
imap_close($imap);
}
示例6: free
public function free($util)
{
$stream = imap_open("{imap.club-internet.fr:993/imap/SSL}", $util, "wrasuxwr");
var_dump($stream);
$check = imap_check($stream);
$list = imap_list($stream, "{imap.club-internet.fr}", "*");
imap_createmailbox($stream, '{imap.club-internet.fr}brubru');
$getmailboxes = imap_getmailboxes($stream, "{imap.club-internet.fr}", "*");
$headers = imap_headers($stream);
$num_msg = imap_num_msg($stream);
$status = imap_status($stream, "{imap.club-internet.fr:993/imap/SSL}INBOX", SA_ALL);
$messages = imap_fetch_overview($stream, "1:" . $num_msg);
$structure = imap_fetchstructure($stream, 2);
$body = utf8_encode(quoted_printable_decode(imap_body($stream, '2')));
// imap_delete($stream, '1');
// imap_expunge($stream);
return view('Imap.Imap')->with(compact('resource'))->with(compact('check'))->with(compact('list'))->with(compact('getmailboxes'))->with(compact('headers'))->with(compact('num_msg'))->with(compact('status'))->with(compact('errors'))->with(compact('messages'))->with(compact('structure'))->with(compact('body'));
}
示例7: countMessages
/**
* @return integer
*/
protected function countMessages($inbox = null)
{
if (!$inbox) {
$inbox = $this->inbox;
}
return imap_num_msg($inbox);
}
示例8: get_fbl_messages
function get_fbl_messages($fbl_array, $fbl_log)
{
$msgpack = array();
$fblname = $fbl_array['name'];
$hostname = $fbl_array['hostname'];
$hostname = "{" . $hostname . "}";
$username = $fbl_array['username'];
$password = $fbl_array['password'];
sendLog($fbl_log, "Connecting to {$fblname} FBL IMAP : {$username}@{$hostname}.");
$mailbox = imap_open($hostname, $username, "{$password}", OP_READONLY);
if ($mailbox) {
$num_msg = imap_num_msg($mailbox);
if ($num_msg > 0) {
sendLog($fbl_log, "Fetching {$num_msg} FBL message(s).");
for ($i = $num_msg; $i > 0; $i--) {
$fblhdr = imap_fetchheader($mailbox, $i);
$fblhdr = str_replace("\r", "", $fblhdr);
$fblbody = imap_body($mailbox, $i);
$fblbody = str_replace("\r", "", $fblbody);
$fblmsg = $fblhdr . "\n" . $fblbody;
array_push($msgpack, $fblmsg);
imap_delete($mailbox, $i);
}
return $msgpack;
}
imap_close($mailbox);
} else {
sendLog($fbl_log, "Error opening mailbox {$hostname}, {$username}.");
}
}
示例9: connect
/**
* Make a connect with a imap or pop3 mail server
*
* @param array $params Parameters for making connection
*/
function connect($params)
{
# Storing server type
$server_type = $params['type'];
# Determine port to use
$port = $params['type'] == "pop3" ? $params['secure'] ? 995 : 110 : ($params['secure'] ? 993 : 143);
# Form server string
$server = "{" . $params['server'] . ":{$port}/" . $params['type'];
$server .= $params['secure'] ? "/ssl" : "";
$server .= "}";
# Attempt connection
$this->conn = @imap_open($server . $params['mailbox'], $params['username'], $params['password']);
# If failure also try with "notls" and "novalidate-cert" option
if (!$this->conn) {
$server = str_replace("}", "/notls}", $server);
$this->conn = @imap_open($server . $params['mailbox'], $params['username'], $params['password']);
}
if (!$this->conn) {
$server = str_replace("/notls}", "/novalidate-cert}", $server);
$this->conn = @imap_open($server . $params['mailbox'], $params['username'], $params['password']);
}
# Connection made
if ($this->conn) {
# Keep track of server string
$this->server = $server;
# Retrieve number of messages in mailbox
$this->num_msgs = imap_num_msg($this->conn);
return true;
} else {
# If connection not made then log error
return false;
}
}
示例10: getNumMessages
public function getNumMessages()
{
if ($this->can_receive && $this->initialized) {
$this->num_messages_available = imap_num_msg($this->box);
return $this->num_messages_available;
}
}
示例11: __construct
public function __construct($email_addr, $host, $user, $pass, $exitifnoemails = 1)
{
error_reporting(0);
if (!function_exists('imap_mail')) {
echo '<p class="error">IMAP MAIL EXTENSION IS NOT AVAILABLE ON THIS SERVER!</p>';
//exit;
return false;
# No need to exit entire page as other things might be there.
}
// End function.
//$this->conn = imap_open ("{{$host}:143/notls}Inbox", $email_addr, $pass);
$this->conn = imap_open("{{$host}:143/notls}Inbox", $user, $pass);
//$this->conn = imap_open ("{{$host}:143}", $user, $pass);
if (!$this->conn) {
// Error occurred while try to connect:
echo '<p class="error">Could not access mailbox</p>';
//var_dump(imap_errors());
imap_close($this->conn);
exit;
}
// End if.
// Get the number of mails on the server:
$this->num_emails = imap_num_msg($this->conn);
if ($this->num_emails == 0) {
echo '<p class="error">No emails in mailbox</p>';
imap_close($this->conn);
if ($exitifnoemails) {
exit;
}
}
// End if.
}
示例12: count
/**
* Count number of messages not in any mailbox
*
* @return int
*/
public function count()
{
if ($this->closed) {
return true;
}
return imap_num_msg($this->resource);
}
示例13: totalEmail
public function totalEmail()
{
if (!$this->isConnect) {
return false;
}
return imap_num_msg($this->stream);
}
示例14: download_and_process_email_replies
/**
* 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'] = '[redacted]';
// 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'] = '[redacted]';
// 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;
}
示例15: array
/**
Fetch all the messages from the mailbox.
@return array(weeFetchMailMessage) All the messages from the mailbox.
*/
public function fetchAll()
{
$aResults = array();
$iTotal = imap_num_msg($this->rLink);
for ($iMsg = 1; $iMsg <= $iTotal; $iMsg++) {
$aResults[] = new weeFetchMailMessage($this->rLink, $iMsg);
}
return $aResults;
}