How can I view the result (final mail) with the email transport class "Debug" in CakePHP 3? Or where can I find the returned result? There's no detailled information about email debugging in the book.
In config/app.php
it says
// 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
So I set
'EmailTransport' => [
'default' => [
'className' => 'Debug',
],
],
And in a test controller:
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(['[email protected]' => 'My Site'])
->to('[email protected]')
->subject('Here the subject')
->send('Here the mail content'));
}
}
But where is the result (final mail) saved or shown?
I expected the Debug result in /tmp/
or /logs/
but could't find any information about the final mail there.
If I view the testpage in Browser (localhost/test/email_test/
) nothing is displayed (as I don't know what to add in the view template for email debugging). There's also no information about the mail in the CakePHP-DebugKit...
(I'm currently testing this with CakePHP 3.1 beta if that is relevant)
'log' => true
didn't work for me, I still couldn't find any log entries of the mail. Anyway, thedebug($result)
worked, thank you. But I think this is not really usefull, because the debugging requires to many changes (double configuration in app.php, add your sugested code in controller...). It would be more usefull, if I just have to replacedefault
todebug
in the controller once when calling$email = new Email('debug');
and then get a debug log entry... Anyway, thank you! – Fencesitter