Getting a list of all users mail addresses in a hook

I have again a question about email function inside a hook.
Same setup as here: Notifications to all users if new block is posted - #8 by texnixe

I am looking for a list of all the users emails.

try {
      'template' => 'new-block',
      'from' => '',
       'to' => *list of all users*,

I tried:
kirby()->users()->email(), ––> null (but there are 3 users for testing)
kirby()->users(), ––> No email addresses
`kirby()->users()->toUsers()->email(), ––> null

The function/object users() should work with the Kirby helper, right?

Kind regards.

You can get an array of all email addresses like this

$emails = kirby()->users()->pluck('email', ',');
1 Like

Yes! Thanks!