Laravel Swift Mail发送带附件的邮件报错 “Swift_IoException The path cannot be empty“处理

复制代码
先说下情况,就是我要做一个发送附件的邮件发送功能,结果,报错:The path cannot be empty。

给我整的有点迷糊,网上也没有类似的问题。

后来,我检查了一下代码,发现有个地方,是需要给附件文件地址的:
php 复制代码
   /**
     * Get the mail representation of the notification.
     *
     * @param mixed $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject('获取报告发送通知')
            ->view('emails.sendReportFile',['data'=>$notifiable->data])
            ->attach($notifiable->report_url);
    }
复制代码
$notifiable->report_url就这个。

一检查这里的变量没值,所以,才导致了这个问题。

记录一下,希望有用。
相关推荐
梅羽落2 小时前
python武器化开发_01
开发语言·python·php
兮动人2 小时前
Fatal error: Uncaught think\exception\ErrorException: SourceGuardian Loade
android·php
catchadmin3 小时前
2026 年 PHP 开发者进阶 快速高效开发学习习惯
学习·php
Web极客码3 小时前
深入解析WordPress的functions.php文件及其高效使用方法
开发语言·php
catchadmin4 小时前
CatchAdmin 2025 年终总结 模块化架构的进化之路
架构·php·开源软件
微爱帮监所写信寄信4 小时前
微爱帮监狱寄信写信小程序PHP底层优化框架
java·开发语言·数据库·spring·微信·php·mybatis
小虎哥-技术博客13 小时前
ThinkPHP 5.x 到 8.x 行为扩展迁移指南
php
小虎哥-技术博客18 小时前
ThinkPHP 5 到 ThinkPHP 8 路由迁移完整指南
php
yangSnowy20 小时前
PHP的运行模式
开发语言·php