Laravel-发送带有标识的电子邮件

Laravel-发送带有标识的电子邮件,laravel,image,email,Laravel,Image,Email,我想发送一封电子邮件,将徽标附在电子邮件正文中。我用的是拉威尔。但每当我试图附加一个图像时,它并没有显示在身体上。相反,它是作为附件发送的。任何建议或文章链接都会对我有帮助 我得到的结果 样本 <?php namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Qu

我想发送一封电子邮件,将徽标附在电子邮件正文中。我用的是拉威尔。但每当我试图附加一个图像时,它并没有显示在身体上。相反,它是作为附件发送的。任何建议或文章链接都会对我有帮助

我得到的结果

样本

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SubscribeMail extends Mailable
{
    use Queueable, SerializesModels;

    public $data;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Test Mail')->view('mails.subscribe');
    }
}
    <div class="wrapper">
        <div class="container">
            <header class="header">
                <h2 class="header-text">ITEC - International Training and Education Counsel</h2>
            </header>

            <section class="body">
                <table class="info-table" cell-padding="5">
                    <thead>
                        <tr>
                            <th colspan="2">
                                <a href="https://www.google.com/url?sa=i&url=https%3A%2F%2Fen.m.wikipedia.org%2Fwiki%2FFile%3AOikya_Front_Logo.png&psig=AOvVaw1gZAn58ULm8UEoqIhPaGNC&ust=1622533229901000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDEirm18_ACFQAAAAAdAAAAABAP">
                                 <img src="https://itecounsel.com/public/assets/images/logo.png" alt="Image" style="width: 100px;">

                                </a>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong class="point">Student Name: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Contact: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Email: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Nationality: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Qualification: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Relevant Work Exprience: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Work Location: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Designation: </strong></td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </section>
        </div>
    </div>

可邮寄

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SubscribeMail extends Mailable
{
    use Queueable, SerializesModels;

    public $data;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Test Mail')->view('mails.subscribe');
    }
}
    <div class="wrapper">
        <div class="container">
            <header class="header">
                <h2 class="header-text">ITEC - International Training and Education Counsel</h2>
            </header>

            <section class="body">
                <table class="info-table" cell-padding="5">
                    <thead>
                        <tr>
                            <th colspan="2">
                                <a href="https://www.google.com/url?sa=i&url=https%3A%2F%2Fen.m.wikipedia.org%2Fwiki%2FFile%3AOikya_Front_Logo.png&psig=AOvVaw1gZAn58ULm8UEoqIhPaGNC&ust=1622533229901000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDEirm18_ACFQAAAAAdAAAAABAP">
                                 <img src="https://itecounsel.com/public/assets/images/logo.png" alt="Image" style="width: 100px;">

                                </a>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong class="point">Student Name: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Contact: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Email: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Nationality: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Qualification: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Relevant Work Exprience: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Work Location: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Designation: </strong></td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </section>
        </div>
    </div>

您有语法错误,我是说花括号使用了两次,请删除它,然后再试一次

  <img src="{{$message->embed(asset('assets/images/logo.png'))}}"/>
embed(资产('assets/images/logo.png'))}”/>
你能试试这个吗。
embed('/assets/images/logo.png')}/>

经过几次研究,我找到了解决方案。将图像包装到表中对我很有用

代码

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SubscribeMail extends Mailable
{
    use Queueable, SerializesModels;

    public $data;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Test Mail')->view('mails.subscribe');
    }
}
    <div class="wrapper">
        <div class="container">
            <header class="header">
                <h2 class="header-text">ITEC - International Training and Education Counsel</h2>
            </header>

            <section class="body">
                <table class="info-table" cell-padding="5">
                    <thead>
                        <tr>
                            <th colspan="2">
                                <a href="https://www.google.com/url?sa=i&url=https%3A%2F%2Fen.m.wikipedia.org%2Fwiki%2FFile%3AOikya_Front_Logo.png&psig=AOvVaw1gZAn58ULm8UEoqIhPaGNC&ust=1622533229901000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDEirm18_ACFQAAAAAdAAAAABAP">
                                 <img src="https://itecounsel.com/public/assets/images/logo.png" alt="Image" style="width: 100px;">

                                </a>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong class="point">Student Name: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Contact: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Email: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Nationality: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Qualification: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Relevant Work Exprience: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Work Location: </strong></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><strong class="point">Designation: </strong></td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </section>
        </div>
    </div>

ITEC-国际培训和教育顾问
学生姓名:
联系方式:
电子邮件:
国籍:
资格认证:
相关工作经验:
工作地点:
名称:

不工作。。图像是broken@Rajin.try一次尝试在src中添加图像url进行测试。这次它作为附件文件工作。但是我想以模板的形式发送。您是否尝试过在代码中嵌入(asset('assets/images/logo.png')}}”/>花括号两次。请检查我的更新答案