Jump to content

can u gimme a sample curl php code to login to any mailserver.


prady

Recommended Posts

you might say this is in violation of one of the forum rules...

All request for code to be written for you should be posted under the freelance section. No exceptions.

 

 

but you can try google for free! :-P

 

To be honest Every mail server probably required different fields and submition variables so, if your looking for a universal curl script...looks doubtfull...google curl+php+'your mail service' and you should get some good results i hope...

 

cheers!

Link to comment
Share on other sites

no no, i need something that i can take as a sample....

 

gmail

yahoo

orkut

 

nething wud do...

i l read it and understand how it works... thats all..

 

i have been scratching myhead onthis for abt a week now.. none of my codes seem to work

 

Link to comment
Share on other sites

code 1

<?php
$username = "username";
$password = "password";

// Initialise cURL
$c = curl_init('https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=zpwhtygjntrz&scc=1&ltmpl=default&ltmplcache=2
');

$headers = array(
    "Host: gmail.com",
"Email:$username",
"Passwd:$password",
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language: en-us,en;q=0.5",
"Accept-Encoding: gzip,deflate,html",
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Keep-Alive: 300",
"Connection: keep-alive");

curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($c, CURLOPT_COOKIESESSION, true);
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($c, CURLOPT_UNRESTRICTED_AUTH, 1); 
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($c, CURLOPT_TIMEOUT, 7); // time out after 3s
curl_setopt($c, CURLOPT_MAXREDIRS, 4);



$str = curl_exec($c);
echo $str;

curl_close($c);
?>

 

this is the first set of code {not working) (i changed the username and password)

 

code 2

<?php>
$login = "https://www.google.com/accounts/ServiceLoginAuth?service=mail";

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $login);
curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, "Email=',myusername'&
								 Passwd='mypassord'&
								 continue='http://mail.google.com/mail/?ui=html&zy=l'&
								 service='mail'&
								 rm='false'&
								 ltmpl='false'&
								 h1='en'&
								 ltmpl='default'&
								 scc='1'&
								 GALX='8eKZr_QRh9E'");



curl_setopt($c, CURLOPT_RANGE, "0-4096");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // return to var
curl_setopt($c, CURLOPT_FAILONERROR, 1); // dont hang
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($c, CURLOPT_TIMEOUT, 7); // time out after 3s
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_MAXREDIRS, 4);
$login_done = curl_exec($c);

echo $login_done; 
?>

 

this is the second set of code, even this is nt working

 

code 3

<?php
$ch = curl_init();
$username='myusername';
$password='mypassword';
$postdata="Email=$username&Passwd=$password&continue=https://www.mail.google.com";
curl_setopt ($ch, CURLOPT_URL,"https://www.mail.google.com");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $gacookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $gacookie);
curl_setopt ($ch, CURLOPT_REFERER, "https://www.gmail.com");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$AskApache_result = curl_exec ($ch);
curl_close($ch);
unlink($gacookie);
?>

 

This is code 3, this is not working as well

 

Code 4

?php

// Initialise cURL
$c = curl_init('https://www.google.com/accounts/ServiceLoginAuth?service=mail');

$headers = array(
	Email:myusername,
	Passwd:mypassword,
	continue:http://mail.google.com/mail/?ui=html&zy=l,
	service:mail,
	rm:false,
	ltmpl:false,
	h1:en,
	ltmpl:default,
	scc:1,
	GALX:8eKZr_QRh9E,
	Host: ocsp.thawte.com:80,
	User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4,
	Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8,
	Accept-Language: en-us,en;q=0.5,
	Accept-Encoding: gzip,deflate,
	Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7,
	Keep-Alive: 300,
	Connection: keep-alive,
	Content-Length: 115,
	Content-Type: application/ocsp-request
	0q0o0M0K0I0+
	);

curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($c, CURLOPT_COOKIESESSION, true);
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_RANGE, "0-4096");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FAILONERROR, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_TIMEOUT, 7);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($c, CURLOPT_UNRESTRICTED_AUTH, 1); 
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);

$str = curl_exec($c);
echo $str;

curl_close($c);
?>

 

this is code 4, this is not working as well...

 

I don't know, what to do..i have tried every possibililty.

 

 

 

 

 

 

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.