Email to database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Email to database

Post by aceconcepts »

Hi,

Can anyone point me in the right direction for retrieving my emails into a MySQL database?

I have a script that I send emails from using PHP mail() and would like to store the replies to sent messages in the same database and not really have to open Outlook to read them.

I've tried looking for some examples and tutorials but "emails" and "php" returns a vast amount of info in a search engine.

Anyway, I hope someone knows of a good example/tutorial.

Thanks.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

As far as I know, you would probably have to code some very low level operations to connect to a POP3 mail server and then you would probably be flooded with spam. I don't think I would even try.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Actually its very easy if your hosting control panel allows you to forward emails of an account to a script that can be executed in command-line.
CPanel has an option to forward a mail to a script. Forwarders > Add > Pipe to a Program. So you probably would get ton of results specific to Cpanel powered hosts/sites.

Read this article if you're having root access.
I've tried looking for some examples and tutorials but "emails" and "php" returns a vast amount of info in a search engine.
Search for pipe email. Keyword is pipe.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

If you aren't using cpanel you can just use the imap commands to login to a pop or imap email account and download mail then you could store it into a database.

http://us3.php.net/manual/en/ref.imap.php
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

Superb.

I have root access using php myadmin.

Thanks for your help.
Post Reply