Reputation: 61
I need help guys. I can't get this working. Could you help me?
Thanks in advance!
config/email.php
public $default = array(
'transport' => 'Mail',
'from' => '[email protected]',
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
FeedbacksController.php
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
*
*
*
public function send() {
$email = new CakeEmail('default');
$email->emailFormat('text')
->to('[email protected]')
->from('[email protected]')
->send('Message Body');
}
The above code gives me an error:
Could not send email.
Error: An Internal Error Has Occurred.
Upvotes: 0
Views: 2498
Reputation: 381
You can use this : In the app/config/email.php add this new config
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => '[email protected]',
'password' => 'secret',
'transport' => 'Smtp',
'timeout' => 1
);
After that and in your controller you have to call :
$email = new CakeEmail('gmail');
That is it.
Upvotes: 1
Reputation: 209
In my experience ive had issues setting the ->from to a single string, and have found that doing ->from(array('emailaddress' => 'name')) has been more successful.
Also im not sure if setting a subject value is required to work sucessfully?
Upvotes: 0