I\'ve got a problem with sending mail using CakePHP. Everythings giong well, but i didn\'t receive any single mail , i tired to send to 2 different emails .
//Websit
Please follow the steps:
step 1: In this file (app\Config\email.php) add this:
public $gmail = array(
'transport' => 'Smtp',
'from' => array('site@localhost' => 'Any Text...'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'youremail@example.com',
'password' => 'yourPassword',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
step 2: Add an email template (app\View\Emails\html\sample.ctp)
Email Testing:
step 3: Change the code in your method as shown below:
public function send_my_email() {
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->config('gmail'); //configuration
$Email->emailFormat('html'); //email format
$Email->to('receiveremail@ex.com');
$Email->subject('Testing the emails');
$Email->template('sample');//created in above step
$Email->viewVars(array('first_name'=>'John Doe' ));//variable will be replaced from template
if ($Email->send('Hi did you receive the mail')) {
$this->Flash->success(__('Email successfully send on receiveremail@ex.com'));
} else {
$this->Flash->error(__('Could not send the mail. Please try again'));
}
}