Skip to content

It is not possible to add plain text to a MailMessage in a Notification #33699

@Jubeki

Description

@Jubeki
  • Laravel Version: v7.22.4
  • PHP Version: v7.4.3
  • Database Driver & Version: MySQL v5.7.24

Description:

It is possible to send a html and plain email with a Mail which extends Mailable. If you want to send a Notification and want to send a html and plain email then you get an error because it is not possible to attach a plain view.

Steps To Reproduce:

Not working example with notifications:

  1. Create a new notification with php artisan make:notification TestNotification
  2. Add the following Code to the notification:
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->view('mail.test.html')
            ->text('mail.test.plain'); // Not existing
    }
  1. Execute the toMail-Method

Working Example with Mails:

  1. Create a new notification with php artisan make:notification TestNotification
  2. Add the following aode to the notification:
    public function build()
    {
        return $this->view('mail.test.html')
            ->text('mail.test.plain');
    }
  1. Try to send Mail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions