toEmail($notifiable); if ($data && isset($notifiable['email']) && Validate::is($notifiable['email'], "email")) { $email = new SendEmail; $result = $email ->to($notifiable['email'], $notifiable['nickname']) ->subject(($data['data'] ? $data['data']['template'] : '邮件通知')) ->message('
' . $data['content'] . '
') ->send(); if ($result) { // 发送成功 $notification->sendOk('email'); } else { // 邮件发送失败 \think\Log::write('邮件消息发送失败:用户:' . $notifiable['id'] . ';类型:' . get_class($notification) . ";发送类型:" . $notification->event . ";错误信息:" . json_encode($email->getError())); } return true; } // 没有openid \think\Log::write('邮件消息发送失败,没有 email,或 email 格式不正确:用户:' . $notifiable['id'] . ';类型:' . get_class($notification) . ";发送类型:" . $notification->event); } return true; } }