Tom Schaefer
Tom Schaefer

Reputation: 897

Mail to MySQL Database

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)

Upvotes: 6

Views: 4123

Answers (6)

Chaye Wala
Chaye Wala

Reputation:

Perhaps you should look at www.dbmail.org

Upvotes: 1

Ogre Codes
Ogre Codes

Reputation: 19651

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.

Upvotes: 4

deau
deau

Reputation: 1223

There is a slicehost step-by-step tutorial that takes a unix based machine, installs postfix on it, sets it up to use MySQL and configures it to accept virtual users and serve/receive email from multiple domains.

The set up is clean, fast and secure. Life is good, eh?

http://articles.slicehost.com/email

Upvotes: 1

phatmanace
phatmanace

Reputation: 5031

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

Upvotes: 6

Nico Burns
Nico Burns

Reputation: 17109

Assuming you know how to save the data to mysql already, you will need access to a mail server, either your own, a webhosts, or you could use a free one such as Gmail, or Hotmail.

You can then use PHP's IMAP functions (which can access POP too) to access the mail. Articles which may help you with this: PHP imap info and a tutorial on creating PHP webmail

Upvotes: 3

victor hugo
victor hugo

Reputation: 35858

If you can access the email using POP just have a process checking the email with POP functions and sending everything to your database

Also you could use php IMAP support

Upvotes: 4

Related Questions