如何在Laravel中通过电子邮件发送HTML格式

I am creating a website. In which there is a Registration page. After the user is registered an email is to be sent to his/her email address that user inputs during registration. I tried to send some text without any HTML tags and which was sent successfully. After which I created HTML format and tried again and at that time I got all the words, texts and HTML tags to the email address. Now I want to send the formatted text using the HTML format.

How can I do this ??

Mail HTML format. ( mail.blade.php )

<html>
<head>

</head>

<body>

<div class="row">
    <div class="col-md-6 col-md-offset-3">

        <div class="panel">
            <div class="panel-body">
                <div class="media-block">
                    <div class="media-left" style="white-space:nowrap">
                        <div class="invoice-logo col-md-12">
                            <div class="media-left">
                                <img src="https://1.bp.blogspot.com/-7NRmwzg6NFw/WqYbo3ydbRI/AAAAAAAAAxM/x_ei2ATh_1k7yJq9_TaXOTsdh1Mjm2rxQCLcBGAs/s400/PicsArt_03-12-11.46.14.jpg" style="width: 50%;"></br>
                                <small>Country</small></br>
                                <small>http://www.web.com/</small>
                            </div>
                        </div>
                    </div>
                    <div class="media-body text-right">
                        <h3 class="h1 text-uppercase text-normal mar-no">INVOICE</h3>
                    </div>
                </div>
                <hr class="new-section-sm bord-no">
                <div class="row">
                    <div class="col-xs-6">
                        <address>
                            <strong class="text-main">{{ $Mname }}</strong><br>
                            {{$date}}<br>
                            {{$st}}
                        </address>
                    </div>
                    <div class="col-xs-6">
                        <table class="pull-right invoice-details">
                            <tbody>
                            <tr>
                                <td class="text-main text-bold">Invoice #</td>
                                <td class="text-right text-primary text-bold">Id 1</td>
                            </tr>
                            <tr>
                                <td class="text-main text-bold">Billing Date</td>
                                <td class="text-right">From Date Db</td>
                            </tr>
                            <tr>
                                <td class="text-main text-bold">Amount Due</td>
                                <td class="text-right text-bold text-main">Total</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <hr class="new-section-sm bord-no">
                <div class="table-responsive">
                    <table class="table table-striped invoice-summary">
                        <thead>
                        <tr class="">
                            <th>Description</th>
                            <th class="min-col text-center">Qty</th>
                            <th class="min-col text-center">Price</th>
                            <th class="min-col text-right">Total</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>
                                <strong>Des Db</strong>
                            </td>
                            <td class="text-center">Qty Db</td>
                            <td class="text-center">Price Db}</td>
                            <td class="text-right">Total Db</td>
                        </tr>
                        </tbody>
                    </table>
                    <table class="table invoice-total">
                        <tbody>
                        <tr>
                            <td><strong>TOTAL :</strong></td>
                            <td class="text-bold h4">Total Db</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
</body>
</html> 
  • Inline all the styling. Try not to use class names.
  • Use tables as much as possible. Don't use divs.
  • Try mjml.io if you're trying to make complex HTML template. It'll make your life really simple.

There are 2 way you can solve your problem:

1. Don't use bootstrap and theme classes on your html mail

Use style="" instead of class="", it's called inline style

2. Import CSS to HTML Head

If you need using bootstrap class on your html then you need to copy the CSS code inside the head styling on your html mail

Just pass the view

public function build()
{
    return $this->view('emails.orders.shipped');
}