Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用laravel通过电子邮件发送多张图像_Php_Html_Laravel_Email_Notifications - Fatal编程技术网

Php 使用laravel通过电子邮件发送多张图像

Php 使用laravel通过电子邮件发送多张图像,php,html,laravel,email,notifications,Php,Html,Laravel,Email,Notifications,我想通过电子邮件发送多张图片。我是新来的拉威尔,我不知道如何添加多个附件。但要低于这个方法 发送电子邮件控制器: foreach (json_decode($img_files) as $img_file) { $imgName = $img_file->name; $pathToFile[] = ['path' => public_path() . "\\uploads\\" . $imgName]; } //send the email to the relev

我想通过电子邮件发送多张图片。我是新来的拉威尔,我不知道如何添加多个附件。但要低于这个方法

发送电子邮件控制器:

foreach (json_decode($img_files) as $img_file) {
    $imgName = $img_file->name;
    $pathToFile[] = ['path' => public_path() . "\\uploads\\" . $imgName];
}

//send the email to the relevant customer email
Mail::to($customer_email)->send(new SendMail($customer_firstname, $pathToFile), function ($message) {
    // $message->attach($pathToFile);
    foreach ($pathToFile as $path) {
        $pathToFile = $path->path;

        $message->attach($pathToFile);
    }
});
dd的输出($pathToFile)

在电子邮件模板中,以下是我添加图像的方式:

embed($pathToFile)}“style=“width:600px;高度:335px“>

如上所述,我有一个带有上传图像路径的数组。如何迭代该数组以将其传递给
SendMail
。 谢谢你的帮助

(编辑):这是SendMail类的代码

public function\u构造($customer\u firstname,$pathToFile)
{
$this->customer\u firstname=$customer\u firstname;
$this->pathToFile=$pathToFile;
}
公共功能构建()
{
返回$this->subject('谢谢!-高级汽车诊断(私人)有限公司')
->视图('admin.email\u模板')
->使用('data',$this->customer\u firstname);

}
这可以解决您的问题吗?我看到了,但作为一名新手,使用我的代码很难理解。您能为我编辑代码来解决这个问题吗?sendmail是Mailable@Rwd我编辑了我的代码并添加了它。
array:2 [
  0 => array:1 [
    "path" => "C:\xampp\htdocs\bit-project\public\uploads\photo_2019-11-08_23-11-50.jpg"
  ]
  1 => array:1 [
    "path" => "C:\xampp\htdocs\bit-project\public\uploads\photo_2019-11-08_23-11-55.jpg"
  ]
]