Laravel 5 mail format html with css

Asked

Viewed 616 times

1

I’m sending an email through Mail of Laravel 5

$data = Input::all();
        Mail::send('mails.sendteste', $data, function ($message) {
            $message->from('[email protected]', 'Sistema');
            $message->subject('Teste');
            $message->to('[email protected]');

        });

I’m using the above code that loads a view that contains CSS scripts but when the email comes to me, it doesn’t read the css and the email is all unformatted..

Have some way to set up the Headers as done in pure php?

Note: I tried to use the Laravel Mail Css Inline but had no effect.

  • Where are you opening the emails for testing? This site shows css support in different email clients https://www.campaignmonitor.com/css/ and css link as it is not supported in Gmail for example.

  • @Danielbeff in Outlook 2013

  • I believe that you have to change the template and put the inline css in the view. Support for external links in email clients is limited. So take a look at guides like this https://www.campaignmonitor.com/css/ to know what email clients you want to support to tailor their layout/view to them.

1 answer

2

Take a look at the lavarel documentation https://laravel.com/docs/5.1/mail

Says the following:

Mailing Plain Text By default, the view Given to the send method is assumed to contain HTML. However, by Passing an array as the first argument to the send method, you may specify a Plain text view to send in addition to the HTML view: Mail::send(['html.view', 'text.view'], $data, $callback); Or, if you only need to send a Plain text e-mail, you may specify this using the text key in the array: Mail::send(['text' => 'view'], $data, $callback);

That is, if you want to send the email in text format uses:

Mail::send(['text' => 'view'], $data, $callback);

In HTML format uses

Mail::send(['html' => 'view'], $data, $callback);

Or use the automatic format

Mail::send(['html.view', 'text.view'], $data, $callback);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.