Import XML File into mysql database when received on email
I have an xml file that is emailed to an email address hosted on my web server. I want the ability to import the xml data into my MySQL database as soon as the email is received, thus providing real time updates to my application.
Is this possible and if so how is this acheived. any working scripts or examples would be greatly appreciated.
Thanks and Regards, Ryan
If you want to process it when the eMail is received you have to find out if your eMail server supports any triggers capable of informing your import script. A less live solution would be to have a Cron Job periodically check your mailbox.
PHP has native extensions for accessing IMAP and POP mailboxes. So you just poll the mailbox and if there is a new eMail, you load the xml infile to your database (or do the insert from inside your script by processing it with an XML extension). Make sure you mark the eMail as read, so you dont import it twice.