Send Email CakePHP

CakePHP2.x provides inbuilt component for Email

Just copy and paste the code to send email

var $components =  array(‘Email’);

function sendmail()

{

//$Path = WWW_ROOT.”img”; //set path of file you want to send in attachment
//$fileName = ‘test.jpg’;//name of file to be sent

$name =”abc”;
$this->Email->to = “xyz@gmail.com”;
$this->Email->subject = “Testing email functionality”;

//$this->Email->attachments = array($Path.$fileName);// add attachment
$this->Email->replyTo =”abc@yahoo.com” ;
$this->Email->from =”abc@yahoo.com” ;
$this->Email->fromName = “Joey Hunter”;
$this->Email->sendAs = ‘html’;

$message = “This is test email”
$this->Email->send($message);

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s