downloadMail - Email Match
4 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: November 15, 2016 (RSS)
Hello, All -
This concerns a topic which has been archived:
https://www.interactivetools.com/forum/forum-posts.php?postNum=2230012#post2230012
I'm trying to find a way to match the sender's email address with those present in a list of users. Two methods are suggested in the thread:
if (!in_array($incoming_mail['from'], $allEmails) ( continue; } // skip if email doesn't match
$fromMatchesMember = mysql_count('accounts', array('email' => $incoming_mail['from']));
if ($fromMatchesMember) { etc... }
In practice however, neither seems to work. My guess is because the email in $incoming_mail['from'] contains more data than just the email address. The format looks like this:
Joe Bloggs <joe@bloggs.com>
Is this why the match is failing? If so can someone suggest a fix?
Thanks,
Perchpole
Hi Perch,
Have a look at this:
http://stackoverflow.com/questions/33865113/extract-email-address-from-string-php
It might help...
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Jerry -
You beauty! You've cracked it! Here's what I sued:
$emailAddress = $message['from'];
preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $emailAddress, $matches);
$fromMatchesMember = mysql_count('accounts', array('email' => $matches[0]));
if ($fromMatchesMember) {
do stuff...
}
Thanks again,
:0)
Perch
Hey Perch,
Good to see you've got it working!
Cheers,
Greg
PHP Programmer - interactivetools.com