Friday, December 11, 2009

Send mail function by cake php.

function sendMail($To, $Subject, $MessageFile, $From, $smtp="1")
{
$this->Email->to = $To;
$this->Email->from = $From;

$this->Email->subject = $Subject;
$this->Email->template = $MessageFile;
$this->Email->sendAs = 'both';

if($smtp == 1)
{
$this->Email->smtpOptions = array(
'port' => '25',
'timeout' => '30',
'host' => 'relay.airtelbroadband.in',
'username' => $From,
'password' => 'octal123',
'client' => 'smtp_helo_hostname'
);
}
$this->Email->delivery = 'smtp';

if($this->Email->send())
{
return true;
}
else
{
return false;
}
}