I am working on a website in which I want to format content of an email received.
At this moment it is coming up in one line like this with only value showing up.
Mike [email protected] 9870000000 New York Hello World
The controller which I have used for the email in Laravel is:
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('[email protected]')->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!');
}
}
Problem Statement:
I am wondering what changes I need to make in the controller so that everything shows up in different lines like below with field names at the left and values at the right. At this moment, I am seeing only values as mentioned above.
Name Mike
Email [email protected]
Number 9870000000
City New York
Post Hello World