0

There is a similar question here: "Unable to open file for reading" (Swift_IoException) in Laravel Mailable

However the accepted answer doesn't solve my problem. I also saw the documentation for attachments

I am trying to attach file while sending mail and here is my code.

 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);
        }
    }

I get this error while program enters into if condition.

Swift_IoException Unable to open file for reading [/home/riwaj/Desktop/Project/Library/public/email/home/riwaj/Desktop/Project/Library/public/email/attachment.jpg]

1 Answer 1

0

Try to do this at the root of the project:

chmod -R 777 public
Sign up to request clarification or add additional context in comments.

1 Comment

Anything else that should be done after this? I did this but the problem still persists

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.