Monday, 6 February 2012

api to send mail with click stats and opened mail.

I was struggling out with godaddy, trying to figure out how to send mail, cos every time i tried it gave some or other restriction error.

After spending hours in searching for issue, figured out an alternative "Jango Mail". jango mail is a php webservice to send mail to users. and U can track on clicks and no of mails opened.

You need to signup for jango mail : https://www.jangosmtp.com
and use the username and password while api calling.

Sample code is as below :
<?php

$fromname         = "Karan";
$fromaddress     = "karan.xxx@sample.com";
$toaddress         = 'karan.xxx@sample.com';
$message           = " data here , html or plain text";
$client = new SoapClient("https://api.jangomail.com/api.asmx?WSDL");
$parameters = array
(
    "Username" => (string) "username here",
    "Password" => (string) "password here",
    "FromEmail" => (string) $fromaddress,
    "FromName" => (string) $fromname,
    "ToEmailAddress" => (string) $toaddress,
    "Subject" => (string) $subject,
    "MessagePlain" => (string) $message,
    "MessageHTML" => (string) $message,
    "Options" => (string) "OpenTrack=True,ClickTrack=True"
);

try
{
$response = $client->SendTransactionalEmail($parameters);
echo "Message(s) sent!";
}
catch(SoapFault $e)
{
echo $client->__getLastRequest();
}
?>