我已经尝试过将存储中的文件附加到邮件:
$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
WHat是错误的,我该怎么做?
答案 0 :(得分:0)
您忘记将$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。