I'm trying to get the website I'm developing to send password reminder emails. I had the idea of using my Gmail account just to test. From the Cake cookbook, I've got this code:
$this->Email->from = 'support@site.com';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'notmyrealemail@gmail.com',
'password'=>'notmyrealpassword');
$this->Email->delivery = 'smtp';
$this->Email->from = 'support@imgstore.in';
$this->Email->to = $this->request->data['User']['email'];
$this->Email->subject = 'Your account reset request';
$this->Email->send('testing');
$this->Email->send();
debug($this->Email->smtpError);
However, when this code ges executed I'm geting this error:
Error: Call to a member function messageID() on a non-object
File: C:\xampp\htdocs\site\lib\Cake\Controller\Component\EmailComponent.php
Line: 312
Notice: If you want to customize this error message, create app\View\Errors\fatal_error.ctp
What am I doing wrong here? At the moment I just want to test if my application can email properly. However, would Gmail be a decent way of sending emails to my users in production?
Thanks.
What it seems to be is You did not include the component class into your controller. Include the EmailComponent
into your controller file.
public $components = array('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.