- // send notifications.
- $notif_params = [
- 'type' => Type::MAIL,
- 'otype' => Notify\ObjectType::MAIL,
- 'verb' => Activity::POST,
- 'uid' => $user['uid'],
- 'cid' => $msg['contact-id'],
- 'link' => DI::baseUrl() . '/message/' . $msg['id'],
- ];
-
- notification($notif_params);
-
- Logger::info('Mail is processed, notification was sent.', ['id' => $msg['id'], 'uri' => $msg['uri']]);
+ if ($notification) {
+ $user = User::getById($msg['uid']);
+ // send notifications.
+ $notif_params = [
+ 'type' => Notification\Type::MAIL,
+ 'otype' => Notification\ObjectType::MAIL,
+ 'verb' => Activity::POST,
+ 'uid' => $user['uid'],
+ 'cid' => $msg['contact-id'],
+ 'link' => DI::baseUrl() . '/message/' . $msg['id'],
+ ];
+
+ DI::notify()->createFromArray($notif_params);
+
+ Logger::info('Mail is processed, notification was sent.', ['id' => $msg['id'], 'uri' => $msg['uri']]);
+ }