I want to send data to an emailaddress and save it into a MySQL database (PHP). What is the easiest way to do this? (no form post, no curl etc., just email)
there are a few ways.
use a postfix alias script, basically, postfix receives your mail, and then runs it through a script of your choosing. The contents of the mail appear in STDIN - then you can do as you please with the contents of the mail.
Use a custom mail server like apache james, that is designed to process mail, and 'do something with it'
{A good one I found recently was in the google labs - http://freshmeat.net/projects/subethasmtp} - looked really good.
pls bear in mind that email is not a guaranteed protocol, if you are trying to do app-to-app messaging, then there are probably better ways!
Hope this helps., ace
If your server doesn't have imap but you have an outside system which does have cron you can write a page that checks the email account and loads the data into MySQL then set up a script on a machine that does have cron to wget the mysql page once every X minutes where X is how frequently you want to load data.
Alternately if you know the emails will load quickly you can set up small one field table in your DB with a time stamp. Each time your PHP script runs it checks the time stamp and if it's more than 5 minutes old it calls the email loading script before loading the web page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With