0

Basically I'd be getting an email once a month that contains a link and some text. I need to be able to grab the link from the email and somehow get it to submit the URL to a database. I can do the database stuff on my own, so I just need to know if it's possible to automatically retrieve the URL from the email every month.

If this isn't something I could do with PHP, what other languages could I do it that are common to web servers? Or maybe there's a service that does this somehow?

Jeremy D
  • 105
  • 3
  • 9
  • 1
    Are you receiving the email in a mailbox and then need to [download it via IMAP or POP](http://php.net/manual/en/book.imap.php) from PHP, or do you have the ability to receive the email at the server and [pipe it to a script to be parsed](http://stackoverflow.com/search?q=%5Bphp%5D+pipe+parse+email)? – Michael Berkowski Jun 14 '12 at 02:10
  • 1
    once a month? i would just cut an paste it. –  Jun 14 '12 at 02:44

1 Answers1

1

I don't know if it's the proper way or not to accomplish your task, but this is something that will work.

Say that you want to check your email for new mails each 1 day, then set a cron job each 24h that executes a php file (you can set it as frequent as you want but some web hosting services limit it). In this file you need the code for retrieving your mail (whatever you use) and some code to parse the email and differentiate regular text from the link.

To do this, if the link is a regular html link, just search for "http" and then copy everything after it to the next " ", if it's user-written, you might get to work much more to parse it and avoid bugs, or you might get a different protocol. Just work the file and if you have any question come back to ask again.

EDIT: To answer the actual question, YES, it is possible using cron jobs or some less common alternatives

Community
  • 1
  • 1
Francisco Presencia
  • 8,732
  • 6
  • 46
  • 90