I'm using Laravel for sending emails.
I'm trying to send a email with a message and save in Database.
But this happens:
- The email is sent to the correct address but not the message.
How can I show the message in the view of the email?
This is my function to send the email and save the records in Database:
public function SendEmailGift(AudiobookSendRequest $request, $id) {
$email = $request->addressee;
$message = $request->message;
if (Auth::user()) {
$audioGift = AudioBook::findOrFail($id);
$userCheck = Auth::user()->$id;
$send = AudiobookSend::where(['user_id' => $userCheck, 'audiobooks_id' => $id])->first();
if(empty($send->user_id)) {
$user_id = Auth::user()->id;
$audiobooks_id = $id;
$send = new AudiobookSend;
$send->user_id = $user_id;
$send->audiobooks_id = $audiobooks_id;
$send->name = $request->name;
$send->addressee = $request->addressee;
$send->message = $request->message;
$send->save();
}
Mail::send('emails.send',
array(
'name' => $request->get('name'),
'addressee' => $request->get('addressee'),
'message' => $request->get('message'),
'location' => $id
), function($message) use ($request)
{
$message->from('no-reply@bdc.com.co');
$message->to($request->addressee, $request->name)->subject('Te han regalado un Audiolibro.');
});
return back()->with('info', 'Se ha enviado el regalo exitosamente');
} else {
return redirect()->route('login')->with('validate', 'Por favor inicia sesión para regalar este audiolibro');
}
}
And here is view for mail:
<h1 class="page-header">Biblioteca Digital CONFA.</h1>
</br>
<p class="text-justify font-bold">
{{-- $message -> Debe de mostrar el mensaje, tira error, htmlspecialchars() parece venir vacio desde la función. --}}
{{-- <strong>{!! $message !!}</strong> --}}
<strong>Mensaje</strong>
</p>
Para ver el audiolibro, presiona el siguiente boton.
<a href="{{ route('audiobooks.show', $location) }}" class="btn btn-outline-warning">Presioname</a>
Everything works, except show the message in the email. Please help me =(