I want to send an email with Laravel, for that, no problem, the email is sent. However, the email I want to send includes two tables that I want to show to the user. Once the email is received, half of it is “illegible”. Only the first painting is interpreted, the second is shown in its raw form.
Here is my blade view.
<!-- resources/views/emails/visite/answer.blade.php -->
@component('mail::message')
@lang('Hello'),<br/><br/>
Votre demande de visite planifiée datant du {{ date('d/m/Y', strtotime($planif->created_at)) }} a été @if($planif->etat == 1) acceptée. @else refusée. @endif
@if($planif->etat == 1)
@component('mail::table')
| Nom | Prénom | Société |
|-----------|-----------|-------------|
@foreach(json_decode($planif->final_visiteurs) as $item)
| {{ $item->name }} | {{ $item->firstname }} | {{ $item->societe }} |
@endforeach
@endcomponent
<br/><br/>
@component('mail::table')
| Modèle | Immatriculation |
|---------------|------------------|
@foreach(json_decode($planif->final_vehicules) as $item)
| @if($item->modele != null) {{ $item->modele }} @else Non renseigné @endif | {{ $item->immat }} |
@endforeach
@endcomponent
@endif
Pour plus d'informations, veuillez contacter l'ASIP.
@lang('Sincerely yours')<br>
EamusCork
@endcomponent
Here is the function that sends the email.
public function accept_planif(Request $request, $id){
$planif = PlanificationVisite::findOrFail($id);
$vis_final = [];
if($request->input('vis')){
$vis = json_decode($request->input('vis')[0]);
for($i = 0; $i < count($vis); $i++){
$vis_final[] = [
'name' => $vis[$i]->name,
'firstname' => $vis[$i]->firstname,
'societe' => $vis[$i]->societe,
'document' => $vis[$i]->document
];
}
}
$veh_final = [];
if($request->input('veh')){
$veh = json_decode($request->input('veh')[0]);
for($i = 0; $i < count($veh); $i++){
$veh_final[] = [
'grise' => $veh[0]->grise,
'immat' => $veh[0]->immat,
'modele' => $veh[0]->modele,
];
}
}
$planif->update(['final_visiteurs' => json_encode($vis_final), 'final_vehicules' => json_encode($veh_final), 'etat' => 1]);
$email = new AnswerPlanificationVisite($planif);
Mail::to($planif->email_sent)->locale('fr')->send($email);
return redirect()->route('visite.see_planif');
}
This is how the email is rendered.

I tried to modify the blade view directly using the <table>, <thead>, <tbody>… tags without success. As you can see, the components don’t work any better. I checked the documentation for the use of “Mail”, I don’t think I made an error on the sending function and I use markdown correctly.