lasthourcloud/.tinkerwell/snippets/SendEmail.php

29 lines
485 B
PHP
Raw 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,
Welcome to Coolify Cloud.
Here is your user id: $user->id
EOF
);
});
}