$localFilePath = storage_path()."/app/tous/sales_return/";
$fileNameList = array_filter(array_map(function ($element){
if ($element != '.' && $element != '..'){
return $element;
}
},scandir($localFilePath)));
$emailInfo = ['localFilePath'=>$localFilePath,'filename'=>$fileNameList];
$toList = ['123@qq.com','345@qq.com'];
$subject = '销售/退货每日汇总';
$messages['view']['view_type'] =1;
$messages['view']['attachment'] =1;
Mail::send('verify/verify_email',['subject'=>$subject,'messages'=>$messages,'time'=>date('Y-m-d H:i:s')],function($message) use ($toList,$subject,$emailInfo){
foreach ($toList as $val) {
$message->to($val);
}
//发送多个附件情况用循环调用attach方法
foreach ($emailInfo['filename'] as $value){
$message->attach($emailInfo['localFilePath'].$value);
}
$message->subject($subject);
});
PHP Laravel Email::send 发送邮件扩展
最新推荐文章于 2025-11-25 11:33:33 发布
这段代码展示了如何使用PHP的Mail库发送带有附件的电子邮件。它首先定义了文件路径,筛选出有效的文件名,然后构造邮件信息,包括收件人、主题和附件。最后,通过循环遍历附件并发送邮件。
1835

被折叠的 条评论
为什么被折叠?



