Laravel邮件伪装不打印任何内容 [英] Laravel mail pretend prints nothing
问题描述
我在mail.php
中设置了'pretend' => true,
,创建了new.php
视图:
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('example@example.hu', $user->username)->subject('Account');
});
日志文件中的输出仅是这样:
The output in the log file is only this:
[2013-08-30 11:27:56] log.INFO:假装将邮件发送到:example@example.com [] []
[2013-08-30 11:27:56] log.INFO: Pretending to mail message to: example@example.com [] []
我尝试使用完整的HTML视图,也尝试使用仅包含字符串但不包含变量,但输出相同的另一个视图.
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?
推荐答案
如果在app/config/mail.php
中设置'pretend' => true
,则从不发送邮件,您只会在日志中收到一条消息,如下所示:
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: foo@example.com [] []
但是,如果您离开'pretend' => false
而使用log
驱动程序('driver' => 'log'
,自Laravel 4.2起可用),则无需发送邮件,而是将整个邮件内容写入日志:
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: <da39a3ee5e6b4b0d3255bfef95601890@example.com>
Date: Thu, 17 Jul 2014 14:15:15 +0000
Subject: Welcome!
From: Ahmad <ahmad@example.com>
To: John Smith <foo@example.com>
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Order confirmed!
[] []
这篇关于Laravel邮件伪装不打印任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!