Laravel 5.7.8中损坏的默认电子邮件模板

时间:2018-10-06 22:50:41

标签: php laravel swiftmailer

我对电子邮件模板编码有疑问:

这是我的模板

mail / user-created.blade.php

@component('mail::message')
    # Invoice Paid

    Your invoice has been paid!

    @component('mail::button', ['url' => '#'])
        View Invoice
    @endcomponent

    Thanks,<br>
    {{ config('app.name') }}
@endcomponent

例如在web.php中:

Route::get('/test', function () {
    $message = (new \App\Notifications\UserCreated(\App\User::first()))->toMail('test@email.com');
    $markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));

    return $markdown->render('mail.user-created', $message->toArray());
});

我得到:

Preview in browser

Preview in browser 2

怎么了?

-

我将代码移到左侧:

Code left

Code left 2

2 个答案:

答案 0 :(得分:0)

您的电子邮件模板必须左对齐。只需将所有内容移到左侧即可。

@component('mail::message')
# Invoice Paid

Your invoice has been paid!

@component('mail::button', ['url' => '#'])
View Invoice
@endcomponent

Thanks,<br>
{{ config('app.name') }}
@endcomponent

答案 1 :(得分:0)

我刚刚找到了解决方法:

vendor / tijsverkoyen / css-to-inline-styles / src / CssToInlineStyles.php

第129行:

替换:

$html = $document->saveHTML($htmlElement);

收件人:

$html = $document->saveHTML();

但是为什么?