friendsofhyperf/notification-mail

The Mail Channel for friendsofhyperf/notification.

Maintainers

👁 huangdijia

Package info

github.com/friendsofhyperf/notification-mail

Issues

Documentation

pkg:composer/friendsofhyperf/notification-mail

Fund package maintenance!

huangdijia

hdj.me/sponsors

Statistics

Installs: 2 871

Dependents: 0

Suggesters: 0

Stars: 0

v3.2.1 2026-06-09 14:51 UTC

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 3d87415e47cff4139fd46cfc6255bed2fea775b0

  • huangdijia <huangdijia.woop@gmail.com>
  • zds

mailnotificationhyperfv3.2


README

ä¸­æ–‡č¯´æ˜Ž

👁 Latest Version on Packagist
👁 Total Downloads
👁 GitHub license

Installation

composer require friendsofhyperf/notification-mail

Usage

Use Notifiable trait in Model

<?php

declare(strict_types=1);

namespace App\Model;

use FriendsOfHyperf\Notification\Traits\Notifiable;
use Hyperf\DbConnection\Model\Model;

/**
 * @property int $id 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class User extends Model
{
 use Notifiable;

 /**
 * The table associated with the model.
 */
 protected ?string $table = 'user';
 
 

 // 通įŸĨé‚ŽįŽą
 public function routeNotificationForMail(): string
 {
 return $this->mail;
 }
}

Mail Notifications

php bin/hyperf.php gen:markdown-mail Test

output

namespace App\Mail;

use FriendsOfHyperf\Notification\Mail\Message\MailMessage;
use FriendsOfHyperf\Notification\Notification;

class Test extends Notification
{
 /**
 * Create a new notification instance.
 */
 public function __construct()
 {
 //
 }

 /**
 * Get the notification's delivery channels.
 *
 * @return array<int, string>
 */
 public function via(object $notifiable): array
 {
 return ['mail'];
 }

 /**
 * Get the mail representation of the notification.
 */
 public function toMail(object $notifiable): MailMessage
 {
 return (new MailMessage)->from('xxx@xxx.cn','Hyperf')->replyTo('xxx@qq.com','zds')->markdown('email');
 }

 /**
 * Get the array representation of the notification.
 *
 * @return array<string, mixed>
 */
 public function toArray(object $notifiable): array
 {
 return [
 //
 ];
 }

}
// storage/view/email.blade.php
xxx