Importing contacts from gmail,outlook using php

hi all

  how can we import the contacts(email id) from gmail,yahoo,Hotmail,rediffmail,outlook using php.

can anybody please guide me to do this?. Is there any readymade classes available for importing Contacts from gmail or other mail clients using PHP/Mysql

Please help me


Not sure about the others but outlook will export to a csv file, then you can write a simple script to read this file, I suspect the others are the same as a csv file is quite standard export format

can you explain little more?

csv = comma seperated value

A csv file is a way of organising database material in a format thatz easily read by most other programs, or certainly more easily programmed into applications that are user written. Each element in the exported data is seperated with a comma
ie first,second,third,forth,etc,etc, you can then use functions within PHP to split this data back into whatever format you require for your application

gmail supports csv too, and I think the others support it too.

Check out [fphp]fgetcsv[/fphp] for more details on how to read csv files in php.


But in my case i don’t want to import to csv/Excel format.i will explain what i am doing right now.

I have a login form ia m giving my gmail or outlook username and password

so i want to display my inbox contacts automaticaly to a new page.How can i achieve this?

please help me :mad:

It’s very difficult in case of outlook if possible at all, since it’s running on user computer. In case of the online email services, you could use [fphp]curl[/fphp] functions or better yet snoopy to log in and export them to csv, then read it from there.

I dont know of a way to ‘tap’ into these details without exporting.


Any free scripts or classes available for connecting php to gmail/yahoo/msn etc

I think rather than the classes to connect gmail/yahoo/msn, there should be some API if they provide. But i am not sure and i dont think that the APIs are available for these all. Posting values using curl or fsockopen functions of PHP may be the solution. But for the login, we must know where to post the email address and password which is the difficult task for myself.

If anyone knows i am also curious to know about this.

That is the easiest part.

The harder part is to work out all the post variables, which are often calculated dynamically and are encrypted in most cases. In order to identify all these variables, a HTTP snoofer would be helpful ( My favourite being HttpWatch).

Yes, as php_demon said CURL and Snoopy are the way to go. I would still advice against Snoopy as it used to break frequently and wasn’t updated for quite a long time (though i haven’t checked over the recent state of affairs down there :wink: ). I had one hell of a time trying to get it working for complicated HTTP requests ( espcially those involving SSL).

Even with CURL, be prepared to configure a lot of options( redirections, SSL certificates, and a lot others).

That is the easiest part.

So how can i know easily that where and how the login information is to be passed (with curl or snoopy)? Please i would be very grateful to you if i know from you in case of hotmail that what exactly the url to post the login information and how the info (email id and password) are to be posted.

Do you have any idea via curl or snoopy?

hi all

I found a demo

I have no idea how this is working
please help me

Get a HTTP sniffer extention for your browser and you will know where exactly are the values being posted to.

You won’t know untill you start coding yourself. Have you set up curl in your machine and tried posting to sever? Optionally, you can use the classes that have already been written to do that.