我尝试过将存储中的文件附加到邮件中:
$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是错的,我怎么才能让它工作呢?
发布于 2020-01-12 17:42:21
您忘记将$HOR_IMG & $NIC_IMG添加到传递给Mail::send的闭包的use中,在更新的代码下面。
$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。
https://stackoverflow.com/questions/59705108
复制相似问题