【发布时间】:2021-02-16 05:06:06
【问题描述】:
这里有一个类似的问题:"Unable to open file for reading" (Swift_IoException) in Laravel Mailable
但是,接受的答案并不能解决我的问题。 我还看到了documentation for attachments
我在发送邮件时尝试附加文件,这是我的代码。
public function build()
{
$folder = public_path('/email');
//Get a list of all of the file names in the folder.
$files = glob($folder . '/*');
//dd($files[]);
if (!empty($files)) {
return $this->subject($this->subject)->markdown('mail.newsletter')->with('data', $this->data)->attach(public_path('/email') . $files[0]);
}else{
return $this->subject($this->subject)->markdown('mail.newsletter')->with('data', $this->data);
}
}
程序进入 if 条件时出现此错误。
Swift_IoException 无法打开文件进行阅读[/home/riwaj/Desktop/Project/Library/public/email/home/riwaj/Desktop/Project/Library/public/email/attachment.jpg]
【问题讨论】:
标签: php laravel email laravel-queue