Halp Any PCP programmers here?

Mean Mr. Mustard

Always shouts out something obscene
Sep 30, 2004
69,359
37,692
1,323
53
Uranus
Marklar
₥42,697
Steam
heyfubuddy
DSC_5211.JPG
 

simple

Giant Member
Sep 30, 2004
12,258
14
533
^_^
Marklar
₥5
I'm writing a script that checks an IMAP email account. I can't seem to get the actual email address that I'm receiving an email from. According to this:

http://www.php.net/manual/en/function.imap-fetch-overview.php

Code:
			$overview = imap_fetch_overview($imap, $result);
			$emailaddy = $overview[0]->from;
should return who its from. But it just returns the name, not the actual email. Halpz?
I think if the from name is known you will always get the name instead of the email address when using overview...

try using header instead... something like:

Code:
$header = imap_header($imap, $result);
echo '<p>name: ' . $header->fromaddress . '<p>';
echo '<p>emailaddy: ' . $header->senderaddress . '<p>';
 

fly

omg
Oct 1, 2004
76,228
26,105
1,323
Marklar
₥64,452
Steam
mattressfish
I actually got it working with this:

Code:
// This will get the from address
$header = imap_header($imap, $result);
$from = $header->from;
foreach ($from as $id => $object) {
	$fromaddress = $object->mailbox;
}
 

simple

Giant Member
Sep 30, 2004
12,258
14
533
^_^
Marklar
₥5
I actually got it working with this:

Code:
// This will get the from address
$header = imap_header($imap, $result);
$from = $header->from;
foreach ($from as $id => $object) {
	$fromaddress = $object->mailbox;
}
cool. header 4 teh win
 

fly

omg
Oct 1, 2004
76,228
26,105
1,323
Marklar
₥64,452
Steam
mattressfish
cool. header 4 teh win

So since you seem to know, and I'm really just learning PHP - riddle me this batman...

In that code, $from is an array containing $header->from, right? And then $object is apparently an array as well? $object->mailbox confuses me.