1
votes

My code is like this :

public function toMail($notifiable)
{
    return (new MailMessage)
                ->subject('You have new follower')
                ->greeting('Hello!')
                ->line('Welcome to my application')
                ->line('Thank you');
}

When run, it was only sent to one email, the email when input data.

How do if I want to send an email to 2 or more email?

I read on https://laravel.com/docs/5.3/notifications#mail-notifications, but I did not find it

1

1 Answers

0
votes

Laravel notifications are used to notify single model (in most cases it's user model) via various channels, and one of them is mail. If you want to send email to multiple people, you might consider using Laravel's mailing functionality.

However, since notifications (via email) are also using Laravel's mailing functions, you can simply use this, although I wouldn't recommend it:

public function toMail($notifiable)
{
    return (new MailMessage)
                ->subject('You have new follower')
                ->cc('[email protected]') // I've added this
                ->greeting('Hello!')
                ->line('Welcome to my application')
                ->line('Thank you');
}

edit: Don't know why it doesn't work for you, the method cc() exists in MailMessage class, as shown in this image:

The cc method exists