[英]Sending emails from CakePHP application using Gmail
我正在嘗試獲取正在開發的網站,以發送密碼提醒電子郵件。 我想到了使用我的Gmail帳戶進行測試的想法。 在Cake Cookbook中,我得到了以下代碼:
$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);
但是,當執行此代碼ges時,出現此錯誤:
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
我在這里做錯了什么? 目前,我只想測試我的應用程序是否可以正確發送電子郵件。 但是,Gmail是向生產中的用戶發送電子郵件的一種不錯的方式嗎?
謝謝。
看來是您沒有在控制器中包括組件類。 將EmailComponent
包含在您的控制器文件中。
public $components = array('Email');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.