開発中の Web サイトでパスワード リマインダー メールを送信しようとしています。テストのためだけに Gmail アカウントを使用するというアイデアがありました。Cake のクックブックから、次のコードを取得しました。
$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);
ただし、このコードが実行されると、次のエラーが発生します。
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 は本番環境でユーザーにメールを送信する適切な方法でしょうか?
ありがとう。