Laravel通过电子邮件发送原始HTML

时间:2020-03-08 14:32:43

标签: laravel laravel-6 laravel-mail

我正在尝试发送电子邮件,不幸的是,电子邮件html标签没有NOT被解析,并且用户将html标签视为文本,已经在网上冲浪了12个小时,但是仍然存在问题

降价模板(notification.email.blade.php)

@component('mail::message')
{{-- Greeting --}}
@if (! empty($greeting))
# {{ $greeting }}
@else
@if ($level === 'error')
#@lang('اوه اوه!')
@else
#@lang('سلام!')
@endif
@endif
{{-- Intro Lines --}}
@foreach ($introLines as $line)
{{ $line }}
@endforeach
{{-- Action Button --}}
@isset($actionText)
<?php
switch ($level) {
case 'success':
case 'error':
$color = $level;
break;
default:
$color = 'primary';
}
?>
@component('mail::button', ['url' => $actionUrl, 'color' => $color])
{{ $actionText }}
@endcomponent
@endisset
{{-- Outro Lines --}}
@foreach ($outroLines as $line)
{{ $line }}
@endforeach
{{-- Salutation --}}
@if (! empty($salutation))
{{ $salutation }}
@else
#@lang('با احترام'),{{ config('app.name') }}
@endif
{{-- Subcopy --}}
@isset($actionText)
@component('mail::subcopy')
@lang("اگر مشکلی در کلیک کردن بر روی \":actionText\" دارید, لینک زیر را کپی \n".'و داخل مرورگر گذاشته: [:actionURL](:actionURL)',['actionText' => $actionText,'actionURL' => $actionUrl,])
@endcomponent
@endisset
@endcomponent

vendor / mail / html / message.blade.php

@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ config('app.name') }}
@endcomponent
@endslot
{{-- Body --}}
{{ $slot }}
{{-- Subcopy --}}
@isset($subcopy)
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
@endcomponent
@endslot
@endisset
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {!! date('Y') !!} @lang('تمامی حقوق برای') {!! config('app.name') !!}  @lang('محفوظ می باشد')
@endcomponent
@endslot
@endcomponent

vendor / mail / html / layout.blade.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<style>
@media only screen and (max-width: 600px) {
.inner-body {
width: 100% !important;
}

.footer {
width: 100% !important;
}
}

@media only screen and (max-width: 500px) {
.button {
width: 100% !important;
}
}
</style>

<table class="wrapper" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table class="content" width="100%" cellpadding="0" cellspacing="0">
{{ $header ?? '' }}

<!-- Email Body -->
<tr>
<td class="body" width="100%" cellpadding="0" cellspacing="0">
<table class="inner-body" align="center" width="570" cellpadding="0" cellspacing="0">
<!-- Body content -->
<tr>
<td class="content-cell">
{{ Illuminate\Mail\Markdown::parse($slot) }}

{{ $subcopy ?? '' }}
</td>
</tr>
</table>
</td>
</tr>

{{ $footer ?? '' }}
</table>
</td>
</tr>
</table>
</body>
</html>

电子邮件代码

        return (new MailMessage)
      ->greeting('Hello!')
->line('One of your invoices has been paid!')
->action('View Invoice', '#')
->line('Thank you for using our application!')->markdown('vendor.notifications.email');
    }

某些输出

<tr> <td class="header"> <a href="http://localhost"> Rabter </a> </td> </tr> <tr> <td> <table class="footer" align="center" width="570" cellpadding="0" cellspacing="0"> <tr> <td class="content-cell" align="center"> &lt;p&gt;é 2020 êÃÂçÃÂàíÃÂÃÂàèñçÃÂÃÂíÃÂÃÂø ÃÂàèçôï&lt;/p&gt; </td> </tr> </table> </td> </tr>

我不知道如何解决它,并且已经在本地主机和共享主机上进行了测试 谢谢您的帮助

0 个答案:

没有答案