mardi 12 mars 2019

Laravel 5.7: Sending AnonymousNotifiable notification to multiple recipients in bulk (but hide recipient emails from each other)

I have no technical issues with below approach whatsoever.

I need to send a plain text notification to let's say 3 email addresses.

I use Laravel's notification on demand class:

use Illuminate\Notifications\AnonymousNotifiable as Notification;

$this
    ->notification
    ->route('mail', $notificationRecipients)
    ->notify(new $notificationClass(
        'some title',
        'some content'
    ));

So $this->notification is above Notification injected in __construct. The $notificationRecipients is a flat array of e-mail addresses:

return [
    'foo@local',
    'bar@local',
    'baz@local',
];

When these guys receive e-mail they see each other in a mail client under To: field. I don't want this to happen. I want them to receive this e-mail without knowing who else received it.

I came up with the obvious solution where instead of passing an array or recipients I will simply iterate through e-mails and foreach email I will call above code with ->route('mail', [$singleRecipient]).

This obviously works but slows down the script execution by quantity of recipients (in this case it is 3 times slower).

Is there a way to keep sending one array of recipients in bulk but also tell the AnonymousNotifiable to "separate recipients from each other"?

Thanks for any hints.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TEOM84
via IFTTT

Aucun commentaire:

Enregistrer un commentaire