Laravel邮件Swift_IoException无法打开文件进行读取

问题描述

这里有一个类似的问题:"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]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)