Debugging cakephp 2.0电子邮件调试不工作

Debugging cakephp 2.0电子邮件调试不工作,debugging,email,cakephp,cakephp-2.0,Debugging,Email,Cakephp,Cakephp 2.0,我正在实现电子邮件功能,它也可以正常工作。现在我必须在本地进行调试,所以做了如下所示的一些更改 在app/config/email.php中,我创建了这个 public $test = array( 'from' => 'you@localhost', 'transport' => 'Debug', ); 现在,在我的控制器中,我编写了以下代码 $Email = new CakeEmail('test');

我正在实现电子邮件功能,它也可以正常工作。现在我必须在本地进行调试,所以做了如下所示的一些更改 在app/config/email.php中,我创建了这个

public $test = array(
        'from' => 'you@localhost',
        'transport' => 'Debug',
    );
现在,在我的控制器中,我编写了以下代码

            $Email = new CakeEmail('test');

        $email->template('adddoctor', 'add');

        //$email->emailFormat('html');


        $email->from('sender@example.com');

        $email->to('recipient@example.com');//$data['User']['email_id'];

        $email->subject('Account Detail');


        $email->send();
发送邮件后,它会重定向到索引页。所以在index.ctp文件中我写了

<?php echo $this->Session->flash('email'); ?>

我不想发送真正的邮件,但我只想展示一下。 那么,有谁能告诉我,对于电子邮件调试,我还需要做哪些更改? 这里有人给出了答案


但是不知道该在哪里编写代码?

这是将电子邮件保存到日志中所需的操作,这与您试图实现的另一个问题的解决方案有关:

app/Config/email.php

public $test = array(
    'log' => true
);
您的控制器

$Email = new CakeEmail('test');
$email->template('adddoctor', 'add');
$email->from('sender@example.com');
$email->to('recipient@example.com');
$email->subject('Account Detail');
$email->send();
如果您随后进入app/tmp/logs/debug.log,您将看到您的电子邮件条目,其中包括标题和消息

2012-11-27 14:37:47 Debug: 
From: My Site <me@example.com>
X-Mailer: CakePHP Email
Date: Tue, 27 Nov 2012 14:37:47 +0000
Message-ID: <50ad02b4b1fba42733cc02456a@example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
My message
2012-11-27 14:37:47调试:
发件人:我的网站
X-Mailer:CakePHP电子邮件
日期:2012年11月27日星期二14:37:47+0000
消息ID:
MIME版本:1.0
内容类型:文本/纯文本;字符集=UTF-8
内容传输编码:8比特
我的留言
然而,在我看来,除非你想看到标题,否则这些都是毫无用处的。首先,你无法真正“看到”你的电子邮件是什么样子,其次,电子邮件将继续发送给收件人

如果你想看看你的电子邮件的实际布局/CSS是什么样子的,你最好给自己发一些测试邮件


我不知道为什么Cake放弃了旧的电子邮件调试功能,因为它更有用。

这是将电子邮件保存到日志中所需要做的,这与您试图实现的另一个问题的解决方案有关:

$Email = new CakeEmail('test');
$email->template('adddoctor', 'add');
app/Config/email.php

public $test = array(
    'log' => true
);
您的控制器

$Email = new CakeEmail('test');
$email->template('adddoctor', 'add');
$email->from('sender@example.com');
$email->to('recipient@example.com');
$email->subject('Account Detail');
$email->send();
如果您随后进入app/tmp/logs/debug.log,您将看到您的电子邮件条目,其中包括标题和消息

2012-11-27 14:37:47 Debug: 
From: My Site <me@example.com>
X-Mailer: CakePHP Email
Date: Tue, 27 Nov 2012 14:37:47 +0000
Message-ID: <50ad02b4b1fba42733cc02456a@example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
My message
2012-11-27 14:37:47调试:
发件人:我的网站
X-Mailer:CakePHP电子邮件
日期:2012年11月27日星期二14:37:47+0000
消息ID:
MIME版本:1.0
内容类型:文本/纯文本;字符集=UTF-8
内容传输编码:8比特
我的留言
然而,在我看来,除非你想看到标题,否则这些都是毫无用处的。首先,你无法真正“看到”你的电子邮件是什么样子,其次,电子邮件将继续发送给收件人

如果你想看看你的电子邮件的实际布局/CSS是什么样子的,你最好给自己发一些测试邮件

我不知道为什么Cake放弃了旧的电子邮件调试功能,因为它更有用

$Email = new CakeEmail('test');
$email->template('adddoctor', 'add');
您正在将对象创建为
$Email
并使用为
$Email
是否输入错误

$response = $Email->send();

$response['headers']; // headers as string
$response['message']; // message body with attachments

$this->Session->setFlash($response['headers'].$response['message']);
您正在将对象创建为
$Email
并使用为
$Email
是否输入错误

$response = $Email->send();

$response['headers']; // headers as string
$response['message']; // message body with attachments

$this->Session->setFlash($response['headers'].$response['message']);
确保布局文件中包含以下内容

echo $this->Session->flash();
确保布局文件中包含以下内容

echo $this->Session->flash();