Laravel 邮件 Swift_IoException 无法打开文件进行读取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39019450/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel mail Swift_IoException Unable to open file for reading
提问by Shahid Chaudhary
Im trying to send attachment in email it give below error but when i check given url file is there and download work.
我试图在电子邮件中发送附件它给出以下错误但是当我检查给定的 url 文件是否存在并下载工作时。
Swift_IoException in FileByteStream.php line 144:
Unable to open file for reading [http://sendemail.domain.com/attachment/warburg_brochure.pdf]
回答by Rashmi Jain
I too had the same issue, check the mime type of file you are attaching. To debug more try different extension files.
我也有同样的问题,请检查您附加的文件的 MIME 类型。要调试更多尝试不同的扩展文件。
回答by Joseph Rukundo
You might be giving a wrong path of attachments. the following codes can work when using sync Mail::to($email) ->send();
您可能提供了错误的附件路径。以下代码在使用 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
但是当使用另一个队列驱动程序时,比如 db Mail::to($email) ->queue 你必须提供这样的完整路径
$this->attach(public_path($path)), [
'mime' => 'application/pdf',
]);
That is how my issue got solved! Thanks
我的问题就这样解决了!谢谢
回答by John
I solved using uploading the image
which was not physically exist earlier!
You can try it. Check if all images,liked to the mail are physically exist in the folder.
There may be other issues.
Try to give 777 permission to those images liked to mail template.
我解决了使用uploading the image
哪个早先不存在的问题!你可以试试看。检查邮件中喜欢的所有图像是否实际存在于文件夹中。可能还有其他问题。尝试给喜欢的那些图像 777 权限邮件模板。
回答by Nilanjan Ganguly
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.
我遇到了同样的问题,并通过提供要附加的文件的绝对路径找到了解决方案。使用 Laravel 函数base_path()
获取项目的绝对路径并提及文件的相对路径。
Syntax: base_path('public/myFiles/filename.pdf');
Hope it will help...
希望它会有所帮助...
回答by Arman Hakim Sagar
- give 777 access in folder
- remove white space from path
- still getting error? check log file storage
- 在文件夹中授予 777 访问权限
- 从路径中删除空格
- 仍然出错?检查日志文件存储