0

我尝试notification为我的网站添加,我通过通知创建了 Annoncephp artisan make command:AnnNotification通知。我通过创建通知表php artisan command notification:table。我配置AnnNotification.php了文件,我Notification::send($ users,new AnnouncementNotification($ request-> name));在插入 Annonce 后添加了该行,但太糟糕了,它给了我错误:Expected response code 354 but got code "550", with message "550 5.7.0 Requested action not taken: too many emails per second". 注意:当我想重新配置邮件陷阱时,它只给了我laravel 7+,我创建了我的网站laravel 6

AnnonceController.php

$Annonce->save();
Notification::send($users, new AnnonceNotification($request->name));
return Redirect::to("annonces")
    ->withSuccess('Great! file has been successfully uploaded.');

AnnonceNotification.php

public function __construct($name)
    {
        $this->name = $name;
    }
public function via($notifiable)
    {
        return ['database'];
    }
public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }
public function toArray($notifiable)
    {
        return [
            'name' => $this->name
        ];
    }

主刀片.php

<li>
      <a href="#">Notifications <span class="badge badge-pill badge-success ml-2" style="background: #ff0000;">{{auth()->user()->notifications->count()}}</span></a>
      <ul>
        @forelse(auth()->user()->notifications as $notification)
          <li><a href="index-default.html">{{ $notification->data['name'] }}</a></li>
        @empty
          <li><a href="index-default.html">no record found</a></li>
        @endforelse
      </ul>
  </li>

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=6d************
MAIL_PASSWORD=b6************
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=admin@admin.com
MAIL_FROM_NAME=Admin
4

0 回答 0