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就这个。

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

记录一下,希望有用。
相关推荐
4***V2026 小时前
PHP在微服务通信中的消息队列
开发语言·微服务·php
亿坊电商6 小时前
PHP框架 vs 原生开发:移动应用后端开发实战对比!
开发语言·php
n***29329 小时前
PHP安全编程实践
开发语言·安全·php
b***74889 小时前
PHP在电子商务系统中的构建
开发语言·php
BingoGo10 小时前
PHP8.6 新的 RFC 提案 Context Managers 优雅管理资源生命周期
后端·php
JaguarJack10 小时前
PHP8.6 新的 RFC 提案 Context Managers 优雅管理资源生命周期
php·服务端
月下的郁王子11 小时前
进阶学习 PHP 中的二进制和位运算
android·学习·php
饭九钦vlog15 小时前
修复重装机kali机器上不了网络域名问题一键脚本
服务器·网络·php
未来之窗软件服务17 小时前
幽冥大陆(二十九)监控平台协议常见地址——东方仙盟练气期
开发语言·php·东方仙盟·东方仙盟sdk·监控协议
拾忆,想起18 小时前
Dubbo网络延迟全链路排查指南:从微服务“快递”到光速传输
网络·网络协议·微服务·架构·php·dubbo