View Full Version : Automatic mysql update upon email being recieved
01-25-2007, 05:35 AM
Is there any way to automatically grab the from field from an email, and use it to run a mysql command based on who the email is from?
Right now, I have to manually get the from name and run it through a simple form to update my mysql columns. Is there any way to automate this?
01-25-2007, 06:00 AM
What do you mean? Explain better.
01-25-2007, 06:41 AM
1) User Sends Email
2) I recieve email
3) I take everything before the @ in their email address
4) I change a column value in mysql relating to their email address
How can I automate this?
01-25-2007, 05:08 PM
If you let PHP have access to the email in some way or another (stored as text file) you could basically filter out the From: header using a regular expression:
$matches = array();
preg_match("/^From:(.+)$/", $email, $matches);
if (sizeof($matches)) $email = $matches;
I'm not 100% positive this would work. But I don't see why not.
The easiest way to run this code would be to have a directory with all new emails.
Then use crontab to run this script every X minutes. The script could read all files in a folder, and use the above code to figure out the From address.
Then afterwards delete everything in that directory for the next run.
01-26-2007, 11:13 AM
My host saves emails in files named like this:
But if I open it in notepad it's just the email+headers.
Is there a way to get PHP to read that?
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.