lundi 29 mars 2021

Emails are being send as plain HTML code {notications.hello} instead of actual text Laravel App

This is the body of my email when I'm trying to send a message:

notications.hello
notications.rest_acc_created

notications.login
notications.username

notications.password

notications.reset_pass

notications.thanks_for_using_us

It appears as plain code instead of the actual message that I want rendered.

Here is the actual code for notifications:

<?php

namespace App\Notifications;

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

class RestaurantCreated extends Notification
{
    use Queueable;

    protected $password;
    protected $restaurant;
    protected $user;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($password, $restaurant, $user)
    {
        $this->password = $password;
        $this->restaurant = $restaurant;
        $this->user = $user;
    }

    /**
     * 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)
                    ->greeting(__('notications.hello', ['username' => $this->user->name]))
                    ->subject(__('notications.acc_create', ['app_name'=>env('APP_NAME', '')]))
                    ->line(__('notications.rest_acc_created', ['restoname'=>$this->restaurant->name]))
                    ->action(__('notications.login'), url(config('app.url').'/login'))
                    ->line(__('notications.username', ['email'=>$this->user->email]))
                    ->line(__('notications.password', ['password'=>$this->password]))
                    ->line(__('notications.reset_pass'))
                    ->line(__('notications.thanks_for_using_us'));
    }

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

Here is the .env file and my email configurations:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.ionos.es
MAIL_PORT=587
MAIL_USERNAME=*****
MAIL_PASSWORD=****
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=*****
MAIL_FROM_NAME=****

Any help I would really appreciate it. I have to say that this used to work before but it stopped working.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire