Reading data from an email?

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
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Reading data from an email?

Post by spacebiscuit »

Hi,

I've just found this forum which looks very busy and helpful. It is nice to find like-minded people as it sometimes can get a little lonely coding away all on your own!

Anyway I have a question. I want to know if there is a method that allows for test within an email to be interpretated and read by a php script. I know it is possible to email data input via a web form, but what about the other way around.

I don't think it is possible but I have a customer who would like this functionality built into his web page.

Any feedback would be appreciated.

Thanks,

Rob Burne.

8O
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Read up on the imap functions

Namely imap_body() - BTW, although called IMAP they support POP3 too.

http://www.php.net/imap/

You can call an email body (well anything you like really, headers etc if you read all of the function list for imap_... ) and read it and play with it.

Let us know how you get on... I'll be interested since I recently started a generic POP3 and IMAP webmail app but then put it down and haven't picked it back up since I started some client work. I must go back to this and finish it :lol:
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

Hi,

Thanks for the reply, I should be able to do exactly what I need to do with those functions so thanks again!

However thinking about my problem in more depth I now have a another question.

The data that will be sent in the emails which I want to read will be sent throughout the day at various and random times. Is there a way to have the script execute every x minutes to check the mailbox for new mail? I am guessing not as the php is only executed when a page is called or viewed right? Ideally I want to be able to leave the office in the knowledge that if an email is sent it is read by my script and the data stored.

Is this possible.

Thanks,

Rob.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Read up on cron jobs.

It's basically like using the windows task scheduler, but to run a php script or similar.

CPanel which most web hosts provide access to, generally has the option the schedule cron jobs.

Good luck! :wink:
Post Reply