laravel为电子邮件呈现纯html

jdzmm42g  于 2022-12-19  发布在  其他
关注(0)|答案(1)|浏览(214)

我想发送电子邮件,但电子邮件显示纯html:

public function build(){  
  return $this->subject('finish service')  
        ->view('emails.subscribers',['msg'=>$this->msg]);
}

我的模板:

<!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" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>آریانت</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        * {
            font-family: IRANYekan, Helvetica, Tahoma, Arial, sans-serif;
        }
        img {
            max-width: 100%;
            vertical-align: middle;
        }
        body {
            -webkit-font-smoothing: antialiased;
            -webkit-text-size-adjust: none;
            width: 100% !important;
            height: 100%;
            direction: rtl;
            font-size: 15px;
            background-color: #F1F3F4;
        }
        a {
            color: #2ba6cb;
            text-decoration: none;
        }
        .table-wrapper {
            width: 100%;
            background-color: #F1F3F4;
            max-width: 700px;
            margin: 0 auto;
            direction: rtl;
            padding: 0 40px;
        }
        .table-header,
        .table-body,
        .table-footer {
            width: 100%;
            background-color: #fff;
        }
        .table-header {
            background-image: url(https://www.ariaservice.net/app/uploads/email/bg-header.png);
            background-repeat: no-repeat;
            background-position: center bottom;
            background-size: cover;
            padding: 10px 15px;
        }
        .logo > img {
            height: 50px;
        }
        .table-nav {
            margin: 0;
            padding: 0;
            list-style: none;
            text-align: left;
        }
        .table-nav > li {
            display: inline-block;
        }
        .table-nav > li + li {
            margin-right: 15px;
        }
        .table-nav > li > a {
            font-weight: bold;
            color: #fff;
        }
        .table-nav > li > a:hover {
            opacity: 0.7;
        }
        .table-body {
            padding: 15px 15px 40px;
        }
        .table-price th,
        .table-body td {
            padding: 10px;
        }
        .btn {
            background-color: rgb(63, 141, 247);
            font-weight: bold;
            color: #fff;
            padding: 0 20px;
            border-radius: 37px;
            height: 37px;
            line-height: 37px;
            white-space: nowrap;
            display: inline-block;
        }
        .btn:hover {
            background-color: rgb(87, 190, 146);
            color: #fff;
        }
        .table-price {
            width: 100%;
            border-collapse: collapse;
        }
        .table-price th,
        .table-price td {
            border: 1px solid #000;
        }
        .table-footer {
            background-image: url(https://www.ariaservice.net/app/uploads/email/bg-footer.png);
            background-repeat: no-repeat;
            background-position: center top;
            background-size: cover;
            padding: 0 50px 70px;
        }
        .btn-sup {
            border-radius: 20px;
            background-color: rgb(87, 190, 146);
            color: #fff;
            position: relative;
            text-align: center;
            width: 100%
        }
        .btn-sup > img {
            width: 100px;
        }
        .social-nav {
            margin: 30px 0 0;
            padding: 0;
            list-style: none;
        }
        .social-nav > li {
            display: inline-block;
        }
        .social-nav > li + li {
            margin-right: 15px;
        }
        .social-nav > li > a:hover {
            opacity: 0.7;
        }
        .social-nav > li > a > img {
            height: 32px;
        }
        .bg-blue {
            background-color: rgb(63, 141, 247);
        }
        .bg-green {
            background-color: rgb(87, 190, 146);
        }
    </style>
</head>
<body>
<table class="table-wrapper">
    <tr>
        <td>
            <table class="table-header">
                <tr>
                    <td>
                        <a href="" class="logo"><img src="https://www.ariaservice.net/app/uploads/email/logo.png" alt=""></a>
                    </td>
                    <td>
                        <ul class="table-nav">
                            <li><a href="">خانه</a></li>
                            <li><a href="">هاست لینوکس</a></li>
                            <li><a href="">خرید دامنه</a></li>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td colspan="1000" align="center">
                        <img src="https://www.ariaservice.net/app/uploads/email/icon-header.png" alt="">
                    </td>
                </tr>
            </table>
            <table class="table-body">
                <tr>
                    <td>

                        {{$msg}}

                    </td>
                </tr>
            </table>
            <table class="table-footer">
                <tr>
                    <td>
                        <table class="btn-sup">
                            <tr>
                                <td width="100">
                                    <img src="https://www.ariaservice.net/app/uploads/email/icon-support.png" alt="">
                                </td>
                                <td>
                                    <p>پشتیبانی آنلاین ، آماده پاسخگویی به شماست</p>
                                    <strong dir="ltr">021 9101 2601</strong>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <ul class="social-nav">
                            <li><a href=""><img src="https://www.ariaservice.net/app/uploads/email/icon-twitter.png" alt=""></a></li>
                            <li><a href=""><img src="https://www.ariaservice.net/app/uploads/email/icon-facebook.png" alt=""></a></li>
                            <li><a href=""><img src="https://www.ariaservice.net/app/uploads/email/icon-instagram.png" alt=""></a></li>
                        </ul>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</body>
</html>
rmbxnbpk

rmbxnbpk1#

您需要根据laravel 8的文档使用->with()
所以你的代码是:

/**
* Build the message.
*
* @return $this
*/
public function build()
{
    return $this->subject('finish service')
                ->view('emails.subscribers')
                ->with([
                    'msg' => $this->msg,
                ]);
}

相关问题