Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29748

Laravel-generated email not formatting HTML correctly

$
0
0

I am struggling with email formatting issue, with Laravel. I get the email content (HTML) from the database, which doesn't really matter, but then quotes get added around, the format is wrong and my email looks like this:

t formatting my email corres

Here is my code, thanks a lot for your help!

I tried with 'content' => htmlspecialchars($content) and 'content' => htmlentities($content) but none work, and for the blade file:

<div>
    {{!!$content!!}}
</div>

gives me an error. I also tried

<div>
    {{{$content}}}
</div>

(also an error of unexpected character) and

<div>
    {{$content}}
</div>

(here was the original one)

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Cookie;

class InsuranceEmail extends Mailable
{
    use Queueable, SerializesModels;
    protected $attacheddoc;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($attacheddoc)
    {
        $this->attacheddoc=$attacheddoc;
    }

    /**
     * Build the message.rubr
     *
     * @return $this
     */
    public function build()
    {
        $name = Auth::user()->nom . "" .  Auth::user()->prenom;

        $sqlContent="SELECT texte from blabla";

        $content = DB::connection('blabla')->select( DB::connection('blabla')->raw($sqlContent))[0]->texte;
        $content = str_replace('#memberName#', $name, $content);
        $content = str_replace('"', '', $content); //I tried this, without any hope ;)

        return $this->from('contact@blabla.net')
                ->markdown('emails.blabla')->with([
                    'title' => "Email onject",
                    'memberName' => $name,
                    'content' => $content,
                ])
                ->attach($this->attacheddoc, array(
                    'as' => 'attacheddoc.pdf', 
                    'mime' => 'application/pdf'));
    }
}

Viewing all articles
Browse latest Browse all 29748

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>