【问题标题】:Laravel Mails Swift_IoException Unable to open file for readingLaravel Mails Swift_IoException 无法打开文件进行读取
【发布时间】: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


    【解决方案1】:

    尝试在项目的根目录执行此操作:

    chmod -R 777 public
    

    【讨论】:

    • 这之后还有什么事情要做吗?我这样做了,但问题仍然存在
    猜你喜欢
    • 1970-01-01
    • 2018-07-12
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    • 2013-05-06
    • 1970-01-01
    • 2011-11-19
    • 2022-10-13
    相关资源
    最近更新 更多