I'm using Zend\Mail to retrieve email from my gmail account and process it.
I need some basic info from the email, including, but not limited to, name and email address. For testing purposes, I created a basic script that pulls the email and reads it and displays the results on the screen. For troubleshooting and testing purposes, I am running that basic script through Runscope so I can see errors better and have a better idea of what the script is seeing/reading.
I'm finding that what it displays (using echo or print) is different than what Runscope shows it's getting.
I suppose I can live with that if you could help me strip what's actually getting pulled down to its essentials.
So here's the basic script (private/personal information has been stripped/modified for the forum, of course)
<?php
$nummsgs = 0;
require('../include/zf2/autoload.php');
$zmail_config = array('host' => 'imap.gmail.com',
'port' => 993,
'ssl' => 'ssl',
'user' => 'support@[gmail account].com',
'password' => 'password');
$zmail = new Zend\Mail\Storage\Imap($zmail_config);
$nummsgs = $zmail->countMessages();
if ($nummsgs == 1)
print "Found " . $nummsgs . " message. \n";
else
print "Found " . $nummsgs . " messages. \n";
for($i = $nummsgs; $i > 0; $i--) { //process messages in reverse.
if($mailmsg = $zmail->getMessage($i)) print "Message ".$i." retrieved. \n";
$headerinfo = $mailmsg->getHeaders();
$from = $mailmsg->from;
$name = $mailmsg->getHeaderField('From', 'name');
$email = $mailmsg->getHeaderField('From', 'email');
echo '<pre>';
echo "\$from: ".$from." \n";
echo "\$name: ".$name." \n";
echo "\$email: ".$email." \n";
print_r($mailmsg);
echo '</pre>';
} //end message processing
?>
Nothing too fancy, right?
(continued in the next post due to length restrictions)