I set 'pretend' => true,
in the mail.php
, created this new.php
view:
<body> <div> E-mail: {{ $user->email }}<br> User: {{ $user->username }}<br> Pass: {{ $user->password }}<br> </div> </body>
Then in my controller I use this code to "send" the mail:
$data['user'] = $user; Mail::send('emails.new', $data, function($message) use ($user) { $message->to('[email protected]', $user->username)->subject('Account'); });
The output in the log file is only this:
[2013-08-30 11:27:56] log.INFO: Pretending to mail message to: [email protected] [] []
I tried with a full HTML view, also with another view that contains only strings, no variables, but the output is the same.
Is this the way how this should work? Shouldn't it print the whole message, title, etc? Is there a problem with the code or this is the proper output?
If you set 'pretend' => true
in app/config/mail.php
then no mail is ever sent, you get just a message in the log, like this:
[2014-07-17 14:15:07] production.INFO: Pretending to mail message to: [email protected] [] []
However, if you leave 'pretend' => false
and instead use the log
driver ('driver' => 'log'
, available since Laravel 4.2), then instead of sending the mail, you'll get the whole mail content written into the log:
[2014-07-17 14:15:14] production.DEBUG: Message-ID: <[email protected]> Date: Thu, 17 Jul 2014 14:15:15 +0000 Subject: Welcome! From: Ahmad <[email protected]> To: John Smith <[email protected]> MIME-Version: 1.0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Order confirmed! [] []
If you actually want to view the contents of the message (for instance when testing user account verification or password reset emails) in the /storage/logs logfile; You can modify your local copy of vendor/laravel/framework/src/Illuminate/Mail/Mailer.php and in the logMessages function modify it to look like
protected function logMessage($message) { $emails = implode(', ', array_keys((array) $message->getTo())); $body = $message->getBody(); $this->logger->info("Pretending to mail message to: {$emails} :-: {$body}"); }
Then you will see the body of the message in the logs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With