php - 如何将存储中的文件附加到邮件 - laravel 6
问题描述
我已经尝试将存储中的文件附加到邮件中:
$attachments = OnlineReply::where('ContactNo', $ContactNo)->first() ;
$HOR_IMG= '/home/sameera/Desktop/sewa/sewa/public/storage/'.$attachments['HOR_IMG'];
$NIC_IMG= '/home/sameera/Desktop/sewa/sewa/public/storage/'.$attachments['NIC_IMG'];
//dd($HOR_IMG,$NIC_IMG);
Mail::send('mail.CRepliesSend',$data, function($message) use ($to_name,$to_email)
{ $message->to($to_email)->subject('reply for your add on mangala sewa');
$message->attach($HOR_IMG);
$message->attach($NIC_IMG);
});
但我得到了这个结果:
ErrorException 未定义变量:HOR_IMG
出了什么问题,我怎么能做到这一点?
解决方案
您忘记在更新后的代码下方将$HOR_IMG
&添加$NIC_IMG
到use
传递给的闭包中。Mail::send
$attachments = OnlineReply::where('ContactNo', $ContactNo)->first() ;
$HOR_IMG= '/home/sameera/Desktop/sewa/sewa/public/storage/'.$attachments['HOR_IMG'];
$NIC_IMG= '/home/sameera/Desktop/sewa/sewa/public/storage/'.$attachments['NIC_IMG'];
//dd($HOR_IMG,$NIC_IMG);
Mail::send('mail.CRepliesSend',$data, function($message) use ($to_name,$to_email,$HOR_IMG,$NIC_IMG)
{ $message->to($to_email)->subject('reply for your add on mangala sewa');
$message->attach($HOR_IMG);
$message->attach($NIC_IMG);
});
如果不清楚use
我想将您重定向到这个出色的答案:https ://stackoverflow.com/a/1065197/1580028 。
推荐阅读
- flutter - 如何在颤动中编辑数组中的元素
- amazon-web-services - 使用每个 terraform 将私有路由表附加到 NAT 网关
- html - 如何在 Outlook 桌面(Outlook 2007)中垂直对齐同一 TD 中的图像(标签内)和文本
- python - 从 Python 读取 Mac .numbers 文件
- javascript - 我正在尝试将表格中的总数加在一起,但不知道该怎么做
- javascript - React 没有安装
- docker - 我无法让我的 docker 设置工作,我做错了什么
- apache-flink - 来自 KAFKA KRB5 Kerberos 问题的 FLINK 流式传输
- ios - 本地化运行时间不变
- reporting-services - 对 Visual Studio 和 Microsoft Report Builder 中的 SSRS 之间的差异感到困惑