2016-11-24 3 views
0

Ich habe die Aktivierungsbenachrichtigung überschrieben, aber ich habe ein Problem, um die E-Mail zu senden. Es funktioniert, wenn keine Warteschlange verwendet wird, sonst bleibt es in der Datenbankwarteschlange und ich weiß nicht, wie ich es beheben kann. Ich weiß jedoch, dass die Warteschlange funktioniert, da das Senden einer E-Mail mit der Datenbankwarteschlange funktioniert.Laravel Änderung Aktivierung E-Mail und Warteschlange

So funktioniert das nicht:

<?php 

namespace App\Notifications; 

use Illuminate\Bus\Queueable; 
use Illuminate\Contracts\Queue\ShouldQueue; 
use Illuminate\Notifications\Messages\MailMessage; 
use Illuminate\Notifications\Notification; 

class SendActivationEmail extends Notification implements ShouldQueue 
{ 
    use Queueable; 

    protected $token; 

    /** 
    * Create a new notification instance. 
    * 
    * SendActivationEmail constructor. 
    * @param $token 
    */ 
    public function __construct($token) 
    { 
     $this->token = $token; 
     $this->onQueue('social'); 
    } 

    /** 
    * Get the notification's delivery channels. 
    * 
    * @param mixed $notifiable 
    * @return array 
    */ 
    public function via($notifiable) 
    { 
     return ['mail']; 
    } 

    /** 
    * Get the mail representation of the notification. 
    * 
    * @param mixed $notifiable 
    * @return \Illuminate\Notifications\Messages\MailMessage 
    */ 
    public function toMail($notifiable) 
    { 
     return (new MailMessage) 
      ->subject('Activation email') 
      ->greeting('xxx - Hello!') 
      ->line('You need to activate your email before you can start using all of our services.') 
      ->action('Activate Email', route('authenticated.activate', ['token' => $this->token])) 
      ->line('Thank you for using our application!'); 
    } 

    /** 
    * Get the array representation of the notification. 
    * 
    * @param mixed $notifiable 
    * @return array 
    */ 
    public function toArray($notifiable) 
    { 
     return [ 
      // 
     ]; 
    } 
} 

aber diese Arbeit:

<?php 

namespace App\Notifications; 

use Illuminate\Notifications\Messages\MailMessage; 
use Illuminate\Notifications\Notification; 

class SendActivationEmail extends Notification 
{ 

    protected $token; 

    /** 
    * Create a new notification instance. 
    * 
    * SendActivationEmail constructor. 
    * @param $token 
    */ 
    public function __construct($token) 
    { 
     $this->token = $token; 
    } 

    /** 
    * Get the notification's delivery channels. 
    * 
    * @param mixed $notifiable 
    * @return array 
    */ 
    public function via($notifiable) 
    { 
     return ['mail']; 
    } 

    /** 
    * Get the mail representation of the notification. 
    * 
    * @param mixed $notifiable 
    * @return \Illuminate\Notifications\Messages\MailMessage 
    */ 
    public function toMail($notifiable) 
    { 
     return (new MailMessage) 
      ->subject('Activation email') 
      ->greeting('xxx - Hello!') 
      ->line('You need to activate your email before you can start using all of our services.') 
      ->action('Activate Email', route('authenticated.activate', ['token' => $this->token])) 
      ->line('Thank you for using our application!'); 
    } 

    /** 
    * Get the array representation of the notification. 
    * 
    * @param mixed $notifiable 
    * @return array 
    */ 
    public function toArray($notifiable) 
    { 
     return [ 
      // 
     ]; 
    } 
} 

so etwas wie dies auch funktioniert:

Mail::to($user->email) 
      ->queue(new Welcome($user)); 

und in meiner Datenbank Warteschlange: (Anzahl der Versuche zu erhöhen)

{"job":"Illuminate\\Queue\\[email protected]","data":{"commandName":"Illuminate\\Notifications\\SendQueuedNotifications","command":"O:48:\"Illuminate\\Notifications\\SendQueuedNotifications\":6:{s:14:\"\u0000*\u0000notifiables\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":2:{s:5:\"class\";s:15:\"App\\Models\\User\";s:2:\"id\";a:1:{i:0;i:12;}}s:15:\"\u0000*\u0000notification\";O:43:\"App\\Notifications\\SendActivationEmail\":5:{s:8:\"\u0000*\u0000token\";s:64:\"f594ec1d2c15bf5c51903b1b408100b6de449895a042ddbe701d014b46a2bd8c\";s:2:\"id\";s:36:\"20d8a21a-3a69-47cf-a37d-bc98f2a83600\";s:10:\"connection\";N;s:5:\"queue\";s:7:\"default\";s:5:\"delay\";N;}s:11:\"\u0000*\u0000channels\";a:1:{i:0;s:4:\"mail\";}s:10:\"connection\";N;s:5:\"queue\";s:7:\"default\";s:5:\"delay\";N;}"}} 

Irgendeine Idee?

Antwort

0

Ich habe vergessen, eine Tabelle Benachrichtigungen erstellen und wusste nicht, dass es erforderlich war.

Nur müssen diese zwei Befehlszeilen auszuführen:

php artisan notifications:table 
php artisan migrate