VOOZH about

URL: https://deepwiki.com/friendsofhyperf/components/8-notification-and-mail-systems

⇱ Notification and Mail Systems | friendsofhyperf/components | DeepWiki


Loading...
Last indexed: 14 February 2026 (15d5ca)
Menu

Notification and Mail Systems

The friendsofhyperf/components monorepo provides a multi-channel notification system and comprehensive mail delivery infrastructure. The notification system routes messages through pluggable channels (mail, SMS, database), while the mail component provides a Laravel-style email API built on Symfony Mailer with support for multiple transports and markdown templates.

Overview

The notification and mail infrastructure consists of two primary subsystems:

  1. Notification System (page 8.1) - Multi-channel notification routing via ChannelManager supporting mail, SMS (via EasySMS), database, and custom channels. Models implement the Notifiable trait to enable notify() and notifyNow() methods. Notifications define delivery channels via the via() method and channel-specific formatters like toMail() and toEasySms(). Supports queued notifications through ShouldQueue interface.

  2. Mail Component (page 8.2) - Standalone email sending using Symfony Mailer with MailManager for driver management and Mailable base class for message construction. Supports SMTP (with required scheme configuration), AWS SES/SESv2, Mailgun, Postmark, sendmail, array, and log transports. Provides fluent MailMessage builder, markdown template rendering via Hyperf View Engine, and attachment handling.

Both systems integrate with the broader ecosystem: notifications can use the mail component as a channel, and mail messages can be queued through Hyperf's async queue system. The mail component requires proper transport configuration including connection credentials and, for SMTP, a mandatory scheme parameter (e.g., smtp, smtps).

Sources: CHANGELOG-3.1.md168 src/mail/src/MailManager.php1-330 src/mail/src/Mailable.php1-1157 docs/en/components/notification-mail.md1-111

Component Packages

PackageNamespaceCore ClassesPurpose
friendsofhyperf/notificationFriendsOfHyperf\NotificationNotification, ChannelManager, NotifiableMulti-channel notification routing and delivery
friendsofhyperf/notification-mailFriendsOfHyperf\Notification\MailMailChannel, MailMessageEmail notification channel using mail component
friendsofhyperf/notification-easysmsFriendsOfHyperf\Notification\EasySmsEasySmsChannelSMS notification via overtrue/easy-sms
friendsofhyperf/mailFriendsOfHyperf\MailMailManager, Mailable, Message, MailerStandalone email with Symfony Mailer transports

Package Dependencies: The notification-mail package depends on mail component for email delivery, while the notification package provides the core routing infrastructure. All notification channels are registered through the ChannelManager which resolves channel implementations from the DI container.

Sources: src/.github/profile/README.md29 src/.github/profile/README.md36-38 docs/zh-cn/guide/start/components.md29

Notification System Architecture

The notification component implements a channel-based routing system where notification classes define delivery channels and channel-specific message formatting. The ChannelManager dispatches notifications to registered channel implementations:

Notification Routing Flow


Key Classes and Methods:

  • FriendsOfHyperf\Notification\Notifiable - Trait providing notify() and notifyNow() methods
  • FriendsOfHyperf\Notification\ChannelManager - Central dispatcher implementing send() and driver() methods
  • FriendsOfHyperf\Notification\Notification - Base class with via() method defining channels
  • FriendsOfHyperf\Notification\Mail\MailChannel - Integrates with MailManager from mail component
  • FriendsOfHyperf\Notification\EasySms\EasySmsChannel - Integrates with overtrue/easy-sms library

Notifications can be queued by implementing ShouldQueue interface, which routes them through Hyperf's async queue system. For detailed channel configuration, notification class structure, and queued notification handling, see Notification System.

Sources: docs/en/components/notification-mail.md1-111

Integration with HTTP Client

The HTTP Client component also supports distributed tracing through the GuzzleHttpClientAspect, which injects trace headers into outbound HTTP requests. This enables distributed tracing across both HTTP-based and message-based communication. See HTTP Client for details on HTTP-based communication.

Sources: High-level system diagrams (Diagram 5)