Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 795437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:28:50+00:00 2026-05-14T22:28:50+00:00

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

  • 0

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.
The following code does not work.

$login_url = 'https://www.google.com/accounts/ServiceLoginAuth';
$gmail_url = 'https://mail.google.com/';
$cookie_file = dirname(__FILE__) . '/cookie.txt';

$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);

curl_setopt($ch, CURLOPT_URL, $gmail_url);
// not sure how to set this option
curl_setopt($ch, CURLOPT_REFERER, $login_url);

$output = curl_exec($ch);
curl_close($ch);

echo $output;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:28:50+00:00Added an answer on May 14, 2026 at 10:28 pm

    Enable imap on gmail and use the old fashion php imap library.
    http://mail.google.com/support/bin/answer.py?hl=en&answer=75725
    http://php.net/manual/en/book.imap.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Occasionally , we have to write methods that receive many many arguments , for
I am currently developing an app that reads out SMS/Emails while driving. Many users
Many banks, airlines, etc. offer the possibility to receive text message notifications by entering
I have many emails coming in from different sources. they all have attachments, many
Does anybody know how many emails are limited in the mail() function? I just
I was wondering if anyone knows a good way to regulate how many emails
I have models with many to many relationships like this: class Contact(models.Model): name =
Current scenario: I'm using the gmail oauth api to receive emails on a page.
I received a Too many open files error when tried to do fopen (C++,
I've got the following query to determine how many votes a story has received:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.