Reputation: 1
My controller
App::uses('CakeEmail', 'Network/Email'); //before class begins
//function
public function contact(){
$email = new CakeEmail();
$email->config('smtp');
$email->from('[email protected]');
$email->to('[email protected]');
$email->subject('About');
$email->send('My message');
}
//Email.php in config folder
class EmailConfig {
public $smtp = array(
'transport' => 'Smtp',
'from' => '[email protected]',
'host' => 'smtp.gmail.com',
'port' => 465,
//'timeout' => 30,
'username' => '[email protected]',
'password' => '*****',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}
The error i get is
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\myproject\lib\Cake\Network\CakeSocket.php on line 222
what do i need to change?
I even created the view file in Views/Users/contact.
Do i need to change the view file in View/Email folder?
Upvotes: 0
Views: 2050
Reputation: 121
Remove $email->from('[email protected]');
from your action and try again. Specify From address only in the email config. Then see whether it works.
App::uses('CakeEmail', 'Network/Email'); //before class begins
//function
public function contact(){
$email = new CakeEmail();
$email->config('smtp');
$email->to('[email protected]');
$email->subject('About');
$email->send('My message');
}
//Email.php in config folder
class EmailConfig {
public $smtp = array(
'transport' => 'Smtp',
'from' => '[email protected]',
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 60,
'username' => '[email protected]',
'password' => '*****',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}
Upvotes: 0
Reputation: 1529
You need to increase max_execution_time variable in your php.ini file.
You shouldn't be timing out sending an email through gmail though. Have you configured the smtp options correctly?
from the cake book http://book.cakephp.org/2.0/en/core-utility-libraries/email.html
'You can configure SSL SMTP servers, like GMail. To do so, put the 'ssl://' at prefix in the host and configure the port value accordingly. Example:'
<?php
class EmailConfig {
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => '[email protected]',
'password' => 'secret',
'transport' => 'Smtp'
);
}
?>
Upvotes: 1