5

Im trying to send attachment in email it give below error but when i check given url file is there and download work.

Swift_IoException in FileByteStream.php line 144:
Unable to open file for reading [http://sendemail.domain.com/attachment/warburg_brochure.pdf]
7
  • Check the permission of that directory, what is it? Check if its readable and it not, change the permission to 755 by typing the command: `chmod 755 <directory of the PDF files> Commented Aug 18, 2016 at 13:31
  • This question and its answers can really help you: stackoverflow.com/questions/4531180/php-swift-mailer-problem and also this: laravel.io/forum/… Commented Aug 18, 2016 at 13:36
  • file its directory and parent directory have 755. even file is downloading. Commented Aug 18, 2016 at 13:36
  • Check the link I just posted, those will solve your problem. Commented Aug 18, 2016 at 13:37
  • @d3r1ck tried that upload_max_filesize, etc did not work Commented Aug 18, 2016 at 13:42

6 Answers 6

1

I too had the same issue, check the mime type of file you are attaching. To debug more try different extension files.

Sign up to request clarification or add additional context in comments.

Comments

0

You might be giving a wrong path of attachments. the following codes can work when using sync Mail::to($email) ->send();

$this->attach($path), [
            'mime' => 'application/pdf',
        ]);

But when using another queue driver like db Mail::to($email) ->queue you had to provide the full path like this

$this->attach(public_path($path)), [
        'mime' => 'application/pdf',
    ]);

That is how my issue got solved! Thanks

Comments

0

I have faced same problem and found solution by providing the absolute path of the file you want to attach. Use Laravel function base_path() to get absolute path of your project and mention relative path of your file.

Syntax: base_path('public/myFiles/filename.pdf');

Hope it will help...

Comments

0

I also facing the same problem, after check log file, I found that swift getting file from http:// not directly from filesystem.

In my case I install server behind firewall and use private ip, this make my server unable to access URL (https://newsletter.domain.com/media/images/aee0c6394d02225d1f740dc.jpeg) directly. The problem actually comes from network configuration.

Easy fix from me is edit hosts file add FQDN with it's private ip

192.168.0.2 newsletter.domain.com

Hope it will help...

Comments

0

I also had this issue a couple of times, most of the times the issue is regarding the permission of folder in which your pointing.

Go inside your project where your folder is located. Try go change the permission of your folder like this:

sudo chmod -R 755 yourfoldername

I hope after this you and everybody else who's struggling will not have anymore problems.

P.S. Becareful of giving 777 permission to your folders. I suggest you to dive in some info before doing that.

Comments

0

I solved this using uploading the image which did not physically exist earlier! You can try it. Check if all images linked to the mail physically exist in the folder. There may be other issues. Try to give 777 permission to those images linked to the mail template.

Comments

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.