I need to check the gmail inbox and read the email body of each email and create a case in CRM based on Keywords 'Billing and Loading', I have a working code for reading mails from Gmail but sorting has been the issue.
I have this code
foreach($emails as $email) {
$headerInfo = imap_headerinfo($connection,$email);
$message= imap_fetchbody($connection , $email,1);
if (preg_match('/Bill|load/', $message)) {
if (strpos($message, 'Bill')) {
echo 'billing related issue';
}elseif (strpos($message, 'load')) {
echo 'Loading related issue';
}
}else echo 'doesn\'t exists</br>';
}
This code checks all the mails, finds the keywords but it checks for either Billing or Loading, not for both,. Please help me.
Aucun commentaire:
Enregistrer un commentaire