vendredi 18 août 2023

How to convert a mailable object to plain text version?

I have an old Laravel 5.7 application.

I have a mailable Illuminate\Mail\Mailable object.

I want to use a 3rd party to send my emails which is not within Laravel's default driver. For the API, I need to send the plain-text and the html-text of the mail.

I can retrieve html text like this:

$htmlText = $mailable->render();

But how to I retrieve the plain text?

This is my build of the mailable:

public function build()
{
    return $this->view('emails.newsletter.master')
                    ->text('emails.newsletter.master_text')
                    ->subject('Hallo');
} 

I could not find how to retrieve plain text from mailable from Laravel docs. I also did not find a method inside the Mailable class that would generate the text. I only see that the plain text blade path gets assigned to textView variable.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire