Mohamed Atef
Published in : 2021-12-14
Swift_loException: Unable to open file for reading, I am facing this error when I try to attach a PDF with email in Laravel using markdown, I still getting the same error however the file exists in the correct directory which I use in the assets functions
public function build(){ return $this->subject('New Form submission')->markdown('mails.confirmation')->with([ "fname" => $this->data["fname"], "lname" => $this->data["lname"], "email" => $this->data["email"], "dateOfBirth" => $this->data["dateOfBirth"], "phone" => $this->data["phone"], "address1" => $this->data["address1"], "address2" => $this->data["address2"], "city" => $this->data["city"], "postal" => $this->data["postal"], ])->attach(asset('/storage/pdf/invoice.pdf'), ['mime' => 'application/pdf']); }
Any thoughts on how can I solve this error?
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Mohamed Atef Date : 2021-12-14
Best answers
51
Best answers
51
After a lot of searching i couldn't handle it in the same way, so the only way which worked for me is attaching the link of the PDF into the email with download button, so the functionality should be like this ,
into the controller i am going to save the PDF and generate the link to download the PDF
then I will receive it from the mail class like regular integer
if anyone know how to attach it let us know how you handle it, i searched a lot but this is the only thing which worked for me, Thanks in advance