如何在电子邮件中显示从Laravel发送的图像

问题描述 投票:1回答:1

我正在尝试在电子邮件中显示从LARAVEL传输的图像(在我的Web应用程序中上传)。

收到的邮件图片:

email

目前,我实现了将图像显示为电子邮件的附件,但我的目标是将图像显示为电子邮件的封面照片。电子邮件的内容是在catalogEmail.blade.php文件中开发的。

目录Controller.php

function Sendcatalog (Request $request, $url){

 $this->validate($request, [
      'email'  =>  'required|email'

     ]);

         $language=Language::where('url', '=', $url)->first();
              if(count($language)==0){
                abort(404);
               }      
         $emailStorage= new EmailStorage;
         $emailStorage -> email = $request -> input('email');   
         $emailStorage->save();
         $catalog=Catalog::first();



           $data = array(
            'email'   =>   $request->email,
            'filename'   =>    $catalog->file_name,
            'title'   =>    $catalog->title,
            'content'   =>    $catalog->content,
            'post_thumbnail'   =>    $catalog->post_thumbnail,
            'post_thumbnail2'   =>    $catalog->post_thumbnail2,
        );




     $visitorEmail=$request->email;   
     Mail::to('[email protected]')->send(new SendCatalogInfo($data));
     Mail::to($visitorEmail)->send(new SendCatalog($data));



 return back()->with('successPost', 'You will get soon catalog on your email address');

}

Web.php

Route::post('/sendcatalog/{url}', 'CatalogController@Sendcatalog')->name('catalog.send');

SendCatalog.php(mail.php)

<?php

namespace App\Mail;

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

class SendCatalog extends Mailable
{
    use Queueable, SerializesModels;

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

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {

             return $this->from('[email protected]')->subject('KAJO company')->attach(public_path('uploads/catalogs/pictures/'. $this->data['post_thumbnail2']))->view('email/catalogEmail')->with('data', $this->data);
    }
}

CatalogEmail.blade.php

<h3>Hello, catalog {{ $data['title'] }}</h3>


<p>Hello, catalog {!! $data['contnet'] !!}</p>


          <img src="{{public_path('uploads/catalogs/pictures/'.$data['post_thumbnail2'])}}"/>  
Preuzmite katalog iz linka

<a href="{{asset('storage/upload/'.$data['filename'])}}" class="btn btn-hot text-capitalize btn-xs" download>Preuzmi fajl</a> 
php laravel email
1个回答
1
投票

您必须将tdl添加到图像源地址。像这样的东西:

<img src="http://example.com/{{public_path('uploads/catalogs/pictures/'.$data['post_thumbnail2'])}}"/>  
© www.soinside.com 2019 - 2024. All rights reserved.