在我的控制器中,我返回此视图,我想将其转换为如下所示的电子邮件。视图工作正常,但我的电子邮件没有发送。我不确定为什么。
public function emailRegistrationConfirmation()
{
$user = Auth::user();
$errors = Session::get('error');
$warning = Session::get('warning');
$info = Session::get('info');
$success = Session::get('success');
$return_mail = Config::get('mail.from.address');
$attendeesIds = $user->attendees()->get()->lists('id');
$programs = ScheduledProgram::whereHas('registeredAttendees', function($q) use ($attendeesIds){
$q->whereIn('attendees.id', $attendeesIds);
})->where('registration_start_date', '<=', $today)
->where('end_date', '>=', $today)
->get();
$sent = Mail::send('user/registration/show', compact( 'user','programs', 'programsProcessing', 'cart','errors', 'successes', 'info', 'warning'), function($message) use ($return_mail, $user)
{
$message->to($return_mail, 'Confirmations')
->subject('RECEIPT: ' . $user->first_name . ' ' . $user->last_name);
});
return $sent?'sent':'not sent';
/*OLD return View worked fine*/
return View::make('user/registration/show', compact('user','programs', 'programsProcessing', 'cart'))
->withError($errors)
->withSuccess($success)
->withInfo($info)
->withWarning($warning);
}
我的页面返回not sent
。我想这意味着Mail :: send失败了。
PhpDebugBar显示在电子邮件选项卡中
Message-ID: <f6d6143403eda66af66ada902039c149@dev.registration.innisfillibrary.ca>
Date: Mon, 19 Mar 2018 16:43:27 -0400
Subject: RECEIPT: pwang1 wang
From: automailer <registration@innisfillibrary.ca>
To: Confirmations <registration@innisfillibrary.ca>
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
答案 0 :(得分:0)
在Laravel中发送此类HTML电子邮件,emails.register
表示路径为emails/register.blade.php
Mail::send(['html' => 'emails.register'], [
'url' => url("set-password/some-verify-token"),
'email' => $request->input('email')
], function ($mail) use($email) {
$mail->from(env('SUPPORT_EMAIL'), env('APP_NAME'));
$mail->to($email);
$mail->subject('welcome');
});
返回文件路径错误,因此将其user/registration/show
更改为user.registration.show
,文件路径为user/registration/show.blade.php
return View::make('user.registration.show', compact('user','programs', 'programsProcessing', 'cart'))
->withError($errors)
->withSuccess($success)
->withInfo($info)
->withWarning($warning);
}