composer require friendsofhyperf/notification-mail<?phpdeclare(strict_types=1);
namespaceApp\Model;
useFriendsOfHyperf\Notification\Traits\Notifiable;
useHyperf\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';
// 通知邮箱publicfunctionrouteNotificationForMail(): string
{
return$this->mail;
}
}php bin/hyperf.php gen:markdown-mail Testoutput
namespaceApp\Mail;
useFriendsOfHyperf\Notification\Mail\Message\MailMessage;
useFriendsOfHyperf\Notification\Notification;
class Test extends Notification
{
/** * Create a new notification instance. */publicfunction__construct()
{
//
}
/** * Get the notification's delivery channels. * * @return array<int, string> */publicfunctionvia(object$notifiable): array
{
return ['mail'];
}
/** * Get the mail representation of the notification. */publicfunctiontoMail(object$notifiable): MailMessage
{
return (newMailMessage)->from('xxx@xxx.cn','Hyperf')->replyTo('xxx@qq.com','zds')->markdown('email');
}
/** * Get the array representation of the notification. * * @return array<string, mixed> */publicfunctiontoArray(object$notifiable): array
{
return [
//
];
}
}// storage/view/email.blade.php
xxx