Halp Any PCP programmers here?

fly

Osharts 11
Oct 1, 2004
72,281
23,876
1,073
Steam
mattressfish
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?
 

Duke

. . first name's "Daisy" boys
May 12, 2008
55,859
18,143
41
Brandon, FL
I can set up your exchange server, just don't expect me to be smart enough to give you the 411 to haxxorz it.
 

Mean Mr. Mustard

Always shouts out something obscene
Sep 30, 2004
66,997
34,964
1,323
51
Uranus
Steam
heyfubuddy
DSC_5211.JPG
 

simple

Giant Member
Sep 30, 2004
12,258
14
533
^_^
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

Osharts 11
Oct 1, 2004
72,281
23,876
1,073
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
^_^
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

Osharts 11
Oct 1, 2004
72,281
23,876
1,073
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.