Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: imap_header - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imap_headerinfo" width="11" height="7"/> <imap_getsubscribed
Last updated: Mon, 05 Feb 2007

view this page in

imap_header

(No version information available, might be only in CVS)

imap_header — imap_headerinfo() のエイリアス

説明

この関数は次の関数のエイリアスです。 imap_headerinfo().



add a note add a note User Contributed Notes
imap_header
gungp720 at yahoo dot com
20-Nov-2002 06:02
To convert date format from mail header to dd/mm/yyyy H:i use this :
<?
$tgl1
= strtotime($msg->date); //convert to timestamp
$tgl2 = date("d/m/Y H:i",$tgl1); //format date from timestamp
echo $tgl2;
?>
hope this help :)
shader76
04-Oct-2002 09:49
if you need to grab other fields that are not parsed out by imap_header then use
imap_fetchheader to retrieve the entire email header and do the work yourself.
15-May-2002 09:08
I just wanted to state what all these variables were producing considering it isnt documented anywhere that I have been able to find on this site:

the object that imap_mailboxmsgs returns has the following fields for the pop3 driver:

array(
     Unread =>
     Deleted =>
     Nmsgs => 
     Size=>     
     Date=>   
     Driver=> 
     Mailbox=>
     Recent=>
)

imap_header returns the following array for the pop3 driver:

stdClass Object (
   date=>
   Date=>
   subject=>
   Subject=>
   toaddress=>
   to=> array stdClass Object (
       mailbox=>
       host=>
     )
   fromaddress=>
   from=> array stdClass Object (
       personal=>
       mailbox=>
       host=>
   )
   reply_toaddress=>
   reply_to=> array stdClass Object (
       personal=>
       mailbox=>
       host=>
   )
   senderaddress=>
   sender => array stdClass Object (
       personal=>
       mailbox=>
       host=>
   )
   Recent=>
   Unseen=>
   Flagged=>
   Answered=>
   Deleted=>
   Draft=>
   Msgno=>
   MailDate=>
   Size=>
   udate=>
)

Also, if you are using a pop3 server and you are having difficulties deleting messages, you will need to call imap_expunge immediately after your call to imap_delete. (this was posted somewhere else..  thanks for that!!)

feel free to drop me a line if this helped you.  Happy coding.
hnesland at samsen dot com
05-Feb-2002 02:36
A way to print your own specified date:

$date = date('d F Y (G:i:s)',
strtotime(strip_tags($headerinfo->udate)));
jwilson at ecominteractive dot net
07-Sep-2001 12:20
It is explained else where on the site but something I struggled with.

To find the size of a message use:

$sizefeed1 = imap_fetchstructure($feed,$messagenumber);
$sizefeed2 = $sizefeed1->bytes;
$size = "$sizefeed2 bytes";
alpha_lam at yahoo dot com dot hk
11-Feb-2001 01:38
I've got a problem when facing some encoded subject or from header like:
=?big5?B?uXG4o7ZXpEg3MTEw?= or
=?iso-8859-1?Q?A7=EB=B2=BC=B6=7D=A9l=21?=
this problem only appears when the poster is using non-Misco$oft reader, and i lastly find the way to solve.
For the =?big5?B?, the encode method is base64, so you can use base64_decode to decode it to the original one, you can use the following to check and decode:

<?php

if(ereg("=\?.{0,}\?[Bb]\?",$strHead)){
 
$arrHead=split("=\?.{0,}\?[Bb]\?",$strHead);
  while(list(
$key,$value)=each($arrHead)){
   if(
ereg("\?=",$value)){
    
$arrTemp=split("\?=",$value);
    
$arrTemp[0]=base64_decode($arrTemp[0]);
    
$arrHead[$key]=join("",$arrTemp);
   }
  }
 
$strHead=join("",$arrHead);
}

?>

For =?iso-8859-1?Q?, it uses quoted printable to encode, you can use quoted_printable_decode to decode, example:

<?php

if(ereg("=\?.{0,}\?Q\?",$strHead)){
 
$strHead=quoted_printable_decode($strHead);
 
$strHead=ereg_replace("=\?.{0,}\?[Qq]\?","",$strHead);
 
$strHead=ereg_replace("\?=","",$strHead);
}

?>
lint at phpcult dot com
03-Aug-2000 10:51
here's something even easier:
<br>
<pre>
$header = imap_header($mail_connection, msgnum);
$from = htmlspecialchars($header->fromaddress);
echo $from;
</pre>
mayorga at tadecom dot com
03-Aug-2000 03:44
If you want to retrieve From address, not From name, use this:
$from=$header->from; $fromaddr=sprintf("%s@%s",$from[0]->mailbox,$from[0]->host);
G dot li at open dot ac dot uk
06-Jul-2000 07:26
Yes, the ref. is quit confusing (to me at least). It will be wise (after spent many hours) to test the type of variable first before it disappointe you. I find $header->From retrurns String, $header->from returns array and its elements are object. Therefore if you want get sender's name for example,
you need: $from = $header->from;
  
       if (is_array($from)){
      
       while(list($key, $val) = each($from)) {
      
       echo $from[0]->personal;
       echo $from[0]->adl;
       echo $from[0]->mailbox;
       echo $from[0]->host;

       }
       }
you will find $header_from is an one element array and this element is an object. Hope anyone else will not wast time here to figure out why retrun is empty.

 
show source | credits | sitemap | contact | advertising | mirror sites