在电子邮件模板laravel中查看多个文件 [英] Multiple files view in email template laravel

查看:68
本文介绍了在电子邮件模板laravel中查看多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组图像路径要附加在电子邮件中.如何在电子邮件模板中查看它们?

I have an array of image path to attach with email. How can i view them in a email template?

SendMailController:

SendMailController:

  $files = collect(json_decode($img_files))->map(function ($file) {
    return public_path('uploads' . DIRECTORY_SEPARATOR . $file->name);
  })->toArray();

  Mail::to($customer_email)->send(new SendMail($customer_firstname, $pathToFile), function($message){
        foreach ($files as $filePath) {
            $message->attach($filePath);
        }
      }
  );

在我的电子邮件模板中:

In my email template:

<img src="{{ $message->embed($filePath) }}" style="width:600px;height:335px">

但这会导致Undefined variable: filePath错误.我怎么能

But this gives, Undefined variable: filePath error. How can i this

推荐答案

尝试这种方式.

Mail::to($customer_email)->send(
    new SendMail($customer_firstname, $files), function($message){
        $size = sizeOf($files); //get the count of number of attachments 

        for ($i=0; $i < $size; $i++) {
            $message->attach($files[$i]);
        }

    }
);

这篇关于在电子邮件模板laravel中查看多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆