Jump to content

Extracting Gmail messages and importing them onto MySQL: Possible?


FForce2195

Recommended Posts

Hello.  I have accomplished several goals thanks to nice people here though I've been writing PHP scripts for just 2 weeks and a few days.  I have a small project to work with for the next few days.  Then I'm thinking about learning how to extract Google's Gmail messages and importing them onto MySQL.  Actually, I don't know if that's possible with PHP.  I suppose it is.  I have seen a website where they sell a library or something for extracting Gmail messages.  I think I ended up with that website after asking a guy named Google or something.  I also searched this place with 'Gmail extract' and didn't get precise hits.

 

If you know where I can go to get information on accessing a Gmail account and extracting messages, please let me know.  If you can give me a brief overview of what to do, that will be great, too.

 

Thanks a lot.

Link to comment
Share on other sites

your need to readup on imap

heres a basic example

<?php
// Connection
$server = "imap.gmail.com:993"; // server & port
$user   = "USERNAME@gmail.com";
$pass   = "PASSWORD";
$mbox   = imap_open("{".$server."/imap/ssl}INBOX", $user, $pass) or die("Error: " . imap_last_error());

echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{".$server."}", "*");

if ($folders == false) {
    echo "Call failed<br />\n";
} else {
    foreach ($folders as $val) {
        echo $val . "<br />\n";
    }
}

echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);

if ($headers == false) {
    echo "Call failed<br />\n";
} else {
    foreach ($headers as $val) {
        echo $val . "<br />\n";
    }
}

imap_close($mbox);
?>

Link to comment
Share on other sites

Well its a starting point :) i won't write the whole thing but that should give you a jump start..

 

as a side note.. i have a static IP at home and at the office but i hear theirs a problem with using gmails imap on a server with a dynamic external IP.. (just something to keep in mind)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.