I\'m trying to send email from a gmail account using CakEmail and SMTP settings .
It would be nice if someone tell the process step by step what to do .
I have a
Use the Swiftmailer component; this is the easiest component to use.
http://bakery.cakephp.org/articles/mhuggins/2008/06/11/improved-swiftmailer-component
There are some changes that you need to do while using this with CakePHP 2.0 onwards. CakePHP 2.0 provides an 'Emails' view directory, which is used to store all the email templates.
Changes to the component:
var
declarations to public
Change public $layout = 'Emails';
to public $viewPath = '/Emails';
Change the render path in _getBodyText
:
$body = $this->controller->render($this->viewPath . DS . 'text' . DS . $view, $this->layout . DS . 'text'.DS.'default');
_getBodyHtml
:$body = $this->controller->render($this->viewPath . DS . 'html' . DS . $view, $this->layout . DS . 'html'.DS.'default');
$bodyText = $this->_getBodyText($view);
$message->setBody($bodyText, "text/plain");
The Swiftmailer component sends a blank email if you set both HTML & TEXT active. It reads from both the email views & adds the body for text. That's the reason to comment these two lines if you want to send html emails.
The second reason is if both are activated & you have content in both email.html.ctp
& email.text.ctp
files, it creates an header issue in that only the text format gets displayed in emails (in reality both the formats are present in header, but it suppresses the html part & shows the text part).