Re: [PHP] problem imap_headerinfo

2008-04-30 Thread Kalle Sommer Nielsen

Hi Richard

Like Chris replied, then the returned value of imap_headerinfo() is an 
stdClass object. You can iterate though

all the object properties like this:
$header = '';

foreach($mail_head as $headerbit => $value)
{
   if(empty($value))
   {
   continue;
   }

   $header .= $headerbit . ': ' . $value . "\r\n";
}

and then:
echo $header;

You might wanna change the $headerbit to look abit more readable =)

Cheers,
Kalle

- Original Message - 
From: "Richard Kurth" <[EMAIL PROTECTED]>

To: "PHP General List" 
Sent: Thursday, May 01, 2008 5:05 AM
Subject: [PHP] problem imap_headerinfo


I get a *Catchable fatal error*: Object of class stdClass could not be 
converted to string  on this line  $mail_head = imap_headerinfo($conn, 
$i);
if I remove it it works fine what would be casing this I really need to 
read the header. I am using php version  5.2.5


$conn = @imap_open("{" . $bouncer['host'] . ":" . $bouncer['port'] . "/" . 
$bouncer['mailtype'] . "/notls}" . $bouncer['mailbox'], 
$bouncer['username'], $bouncer['password']);

$headers = @imap_headers($conn);
   if ($headers) {
 $email_count = sizeof($headers);
 for($i = 1; $i <= $email_count; $i++) {
  # Check the body against all saved patterns
  $mail_head = imap_headerinfo($conn, $i); $mail_body = 
imap_fetchbody($conn, $i, 1);

   echo "mail head: $mail_head\n";
   echo "mail body: $mail_body\n";


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
No virus found in this incoming message.
Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release 
Date: 30-04-2008 18:10






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] problem imap_headerinfo

2008-04-30 Thread Chris
Richard Kurth wrote:
> I get a *Catchable fatal error*: Object of class stdClass could not be
> converted to string  on this line  $mail_head = imap_headerinfo($conn, $i);

RTM.

http://www.php.net/imap_headerinfo

It's an object, not a string.

print_r($mail_head);

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] problem imap_headerinfo

2008-04-30 Thread Richard Kurth
I get a *Catchable fatal error*: Object of class stdClass could not be 
converted to string  on this line  $mail_head = imap_headerinfo($conn, $i);
if I remove it it works fine what would be casing this I really need to 
read the header. I am using php version  5.2.5


$conn = @imap_open("{" . $bouncer['host'] . ":" . $bouncer['port'] . "/" 
. $bouncer['mailtype'] . "/notls}" . $bouncer['mailbox'], 
$bouncer['username'], $bouncer['password']);

$headers = @imap_headers($conn);
   if ($headers) {
 $email_count = sizeof($headers);
 for($i = 1; $i <= $email_count; $i++) {
  # Check the body against all saved patterns
  $mail_head = imap_headerinfo($conn, $i); 
  $mail_body = imap_fetchbody($conn, $i, 1);

   echo "mail head: $mail_head\n";
   echo "mail body: $mail_body\n";


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php