Why wont my CakeEmail send?

108 Views Asked by At

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' => '[email protected]',
    'password' => 'password1',
    'transport' => 'Smtp'
);

// sending/receiver details for email

$this->Email->template = 'resetpw';
$this->Email->from = 'Cafe <[email protected]>';
$this->Email->to = 'Andrew <[email protected]';
$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=============//
}
1

There are 1 best solutions below

0
heatl0rd On

Solved. Forgot to add

App::uses('CakeEmail', 'Network/Email');