I have the following function being called from my view.ctp file after a form button is pressed. However nothing is being recieved. Any advice?
public function email(){
// ============Email================//
/* SMTP Options */
$this->Email->smtpOptions = array(
'port' => '465',
'timeout' => '30',
'host' => 'ssl://smtp.gmail.com',
'username' => 'email1@gmail.com',
'password' => 'password1',
'transport' => 'Smtp'
);
// sending/receiver details for email
$this->Email->template = 'resetpw';
$this->Email->from = 'Cafe <email1@gmail.com>';
$this->Email->to = 'Andrew <email2@gmail.com';
$this->Email->subject = 'Junto Cafe: Password reset';
$this->Email->sendAs = 'both';
$this->Email->delivery = 'smtp';
$this->set('ms', $ms);
$this->Email->send();
$this->set('smtp_errors', $this->Email->smtpError);
// after sending, display a notification
$this->Session->setFlash(__('Check Your Email To Reset your password', true) , 'alert-box', array(
'class' => 'alert-success'
));
// ============EndEmail=============//
}
Solved. Forgot to add
App::uses('CakeEmail', 'Network/Email');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.