lasthourcloud/.tinkerwell/snippets/SendEmail.php

29 lines
487 B
PHP
Raw Permalink Normal View History

2023-11-03 13:38:34 +00:00
<?php
/**
* @label Send Email
* @description Send email to all users
*/
2023-11-03 13:39:11 +00:00
use App\Models\User;
use Illuminate\Support\Facades\Mail;
2023-11-03 13:38:34 +00:00
set_transanctional_email_settings();
$users = User::whereEmail('test@example.com');
2023-11-03 13:38:34 +00:00
foreach ($users as $user) {
Mail::send([], [], function ($message) use ($user) {
$message
->to($user->email)
->subject("Testing")
->text(
<<<EOF
Hello,
2024-03-02 02:37:31 +00:00
Welcome to Last Hour Cloud.
2023-11-03 13:38:34 +00:00
Here is your user id: $user->id
EOF
);
});
}