現在cakephpでメール送信をしようとしてるのですが、うまく行きません。なぜか教えてもらってもいいでしょうか?
バージョン情報
macOS mojave 10.14.6
PHP 7.3.6
- This is email configuration file.
- Use it to configure email transports of Cake.
- @link http://cakephp.org CakePHP(tm) Project
- @package app.Config
- @since CakePHP(tm) v 2.0.0
メールの設定↓
email.php
1class EmailConfig { 2 3 public $default = array( 4 'transport' => 'Mail', 5 'from' => 'testtry@try.com', 6 'charset' => 'utf-8', 7 'headerCharset' => 'utf-8', 8 'log' => true, 9 ); 10}
Controller↓
usersController.php
1class UsersController extends AppController 2{ 3public function recover() 4 { 5 App::uses('CakeEmail', 'Network/Email'); 6 7 $Email = new CakeEmail('default'); 8 $sended = $Email 9 ->to('hogehoge@hoge.com')) 10 ->send('test Message'); 11 } 12}
View↓
recover.ctp
1<h2>Recover Password</h2> 2<?php 3echo $this->Form->create(); 4echo $this->Form->input('email'); 5echo $this->Form->end(); 6?>
error
1Could not send email: unknown 2Error: An Internal Error Has Occurred. 3 4Stack Trace 5APP/Vendor/cakephp/cakephp/lib/Cake/Network/Email/MailTransport.php line 52 → MailTransport->_mail(string, string, string, string, null) 6 $message = implode($eol, $email->message()); 7 8 $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null; 9 $this->_mail($to, $subject, $message, $headers, $params); 10 11'hogehoge@hoge.com' 12'' 13'test Message 14 15' 16'From: testtry@try.com 17X-Mailer: CakePHP Email 18Date: Fri, 09 Aug 2019 17:35:19 +0900 19Message-ID: <5d4d3047a7c440fcb4230014ac120003@localhost> 20MIME-Version: 1.0 21Content-Type: text/plain; charset=UTF-8 22Content-Transfer-Encoding: 8bit' 23null 24APP/Vendor/cakephp/cakephp/lib/Cake/Network/Email/CakeEmail.php line 1183 → MailTransport->send(CakeEmail) 25APP/Controller/UsersController.php line 810 → CakeEmail->send(string) 26'test Message' 27[internal function] → UsersController->recover() 28APP/Vendor/cakephp/cakephp/lib/Cake/Controller/Controller.php line 499 → ReflectionMethod->invokeArgs(UsersController, array) 29APP/Vendor/cakephp/cakephp/lib/Cake/Routing/Dispatcher.php line 193 → Controller->invokeAction(CakeRequest) 30APP/Vendor/cakephp/cakephp/lib/Cake/Routing/Dispatcher.php line 167 → Dispatcher->_invoke(UsersController, CakeRequest) 31APP/webroot/index.php line 192 → Dispatcher->dispatch(CakeRequest, CakeResponse)
なぜmailが送れないかがわかりません。
ちなみに、localhostからsendmailやcakeじゃないphpのスクリプトでの送信はできました。
どなたかcakephp2に詳しい人教えてください。。。