cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Yahoo email with cURL

From: <falcorthedog_at_ca.rr.com>
Date: Fri, 24 Aug 2007 17:32:30 -0700

I've managed to write a PHP script that successfully logs into a user's Yahoo account and can download info such as their address book, etc.

But I was wondering if it was possible to actually send an email from the user's Yahoo account using Yahoo's web based email system. I tried, but couldn't get it to work. Any ideas?

Here is the code I tried:

<?php

$username = "username";
$password = "password";

$emailTo = "emailTo";
$subject = "subject";
$body = "body";

$ch = curl_init();
 
curl_setopt ($ch, CURLOPT_URL, 'http://login.yahoo.com/config/login?');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "login=$username&passwd=$password&.src=&.tries=5&.bypass=&.partner=&.md5=&.hash=&.intl=us&.tries=1&.challenge=ydKtXwwZarNeRMeAufKa56.oJqaO&.u=dmvmk8p231bpr&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.v=0&.chkP=N&.last=&.done=");
 
curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt ($ch, CURLOPT_COOKIEFILE, "cookies.txt");
 
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/419.2.1 (KHTML, like Gecko) Safari/419.3');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_exec ($ch);
//everything above works successfully and logs the user in (assuming correct name and password)... below is an unsuccessful attempt to send an email

curl_setopt ($ch, CURLOPT_URL, 'http://b7.mail.yahoo.com/ym/ziguana.com/Compose?');
curl_setopt ($ch, CURLOPT_POSTFIELDS, "YY=6225&y5beta=yes&y5beta=yes&order=down&sort=date&view=a&To=$emailTo&Subj=$subject&body=$body");

echo curl_exec ($ch);

curl_close($ch);
?>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-08-25