I wanted to write a script to forward my gmail unread messages to another one of my account automatically. I wanted to do this in php.
First I wanted to fetch the unread messages and tried below code. :/
//fucntion to get unread emails taking username and password as parametes
$username = 'XXXXX@gmail.com
$password = 'XXXXX';
function check_email($username, $password)
//url to connect to
$url = "https://mail.google.com/mail/feed/atom
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_ENCODING, "");
$curlData = curl_exec($curl);
//returning retrieved feed
//making page to behave like xml document to show feeds
$feed = check_email("username", "password");
But I am getting following error. Seems like there is something wrong in the xml format. Can somebody help with this?? Or it would also be great if someone can provide me help with full code to automatically forward unread gmail.
XML Parsing Error: junk after document element
Line Number 2, Column 1:<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
I am wondering whether this is the right way to automatically forward my gmail...!!!
I am new and donno the direction...!!
Thanks in advance...!!1