我正在一个网站上工作,我想在其中格式化收到的电子邮件的内容。
此刻,它像这样排成一行,只显示值。
Mike abc@gmail.com 9870000000 纽约 Hello World
我在 Laravel 中用于电子邮件的控制器是:
Class PostingMessageController extends Controller
{
public function create()
{
return view('posting');
}
public function store(Request $request)
{
/*
dd($request->all());
*/
$this->validate($request, [
'name' => 'required',
'email' => 'required|email',
'number' => 'required',
'city' => 'required',
'post' => 'required'
]);
Mail::send('emails.posting-message', [
'msg'=> $request->name . "\r\n"
. $request->email . "\r\n"
. $request->number . "\r\n"
. $request->city . "\r\n"
. $request->post . "\r\n"
], function($mail) use($request) {
$mail->from($request->email, $request->name);
$mail->to('abc@hellworld.com')->subject('Contact Message');
});
return redirect()->back()->with('flash_message', 'thank you, your posting info has been sent to our team. we will reach out as soon as we can to provide next steps!');
}
}
问题陈述:
我想知道我需要在控制器中进行哪些更改,以便所有内容都显示在不同的行中,如下所示,左侧的字段名称和右侧的值。目前,我只看到上面提到的值。
Name Mike
Email abc@gmail.com
Number 9870000000
City New York
Post Hello World