PHP: get contents of a remote webpage that require authentication?

Posted by powerboy on Stack Overflow See other posts from Stack Overflow or by powerboy
Published on 2010-05-16T06:50:55Z Indexed on 2010/05/16 7:00 UTC
Read the original article Hit count: 195

Filed under:

I receive many emails whose contents are of the same pattern, e.g.

Name: XXX
Phone: XXX
Bio: XXX
......

I want to write a PHP script to parse these emails and save the data into a database. I tried to use file_get_contents() to get the contents of these emails.

The problem is that, it requires authentication to access to my emails. Even though I have signed into my email account on the server (localhost actually), file_get_contents() still return the webpage that prompts me to sign in.

So how to access the contents of my emails with a PHP script?

EDIT: it is a gmail account.

© Stack Overflow or respective owner

Related posts about php