【发布时间】:2015-08-07 14:37:28
【问题描述】:
如何在 CakePHP 3 中使用电子邮件传输类“Debug”查看结果(最终邮件)?或者我在哪里可以找到返回的结果? the book中没有关于邮件调试的详细信息。
在config/app.php 中说
// Each transport needs a `className`. Valid options are as follows:
// - Mail : Send using PHP mail function
// - Smtp : Send using SMTP
// - Debug : Do not send the email, just return the result
所以我设置
'EmailTransport' => [
'default' => [
'className' => 'Debug',
],
],
在测试控制器中:
namespace App\Controller;
use App\Controller\AppController;
use Cake\Event\Event;
use Cake\Network\Exception\NotFoundException;
use Cake\Mailer\Email;
class TestsController extends AppController {
public function email_test() {
$email = new Email('default');
$email->from(['website@example.com' => 'My Site'])
->to('destination@example.com')
->subject('Here the subject')
->send('Here the mail content'));
}
}
但是结果(最终邮件)保存或显示在哪里?
我希望在/tmp/ 或/logs/ 中得到调试结果,但在那里找不到有关最终邮件的任何信息。
如果我在浏览器 (localhost/test/email_test/) 中查看测试页,则不会显示任何内容(因为我不知道在查看模板中添加什么以进行电子邮件调试)。 CakePHP-DebugKit 中也没有关于邮件的信息...
(如果相关的话,我目前正在使用 CakePHP 3.1 beta 进行测试)
【问题讨论】:
标签: cakephp-3.0