lundi 7 octobre 2019

How to send email to multiple user email in PHP by set date and hour automatically

I want to send email to multiple user email in PHP automatically by setting a date by the user I mean the user choose a date and hour from input date and I save it on a database then I want to send an email on that date is there any way to PHP do this job automatically because I do this job manually by myself and the number of users is going up and maybe we must send emails in any seconds of a day and I want to do this job in Laravel 5.8 framework when I success on it.

The code I use in a PHP file and run this manually like this:

!!! (I get $UsersEmail array from a database by selecting the date and hour and it's like the array I write in codes) !!!

$UsersEmail = array(
    0 => 'user1@example.com',
    1 => 'user2@site.com',
    2 => 'user3@test.com',
    3 => 'user4@somesite.com',
    4 => 'user5@anohtersite.com',
);

$AllEmail = '';

foreach($UsersEmail as $user){
    $AllEmail .= $user.', ';
}

$to = $AllEmail;

$subject = 'Send Email';

$message = 'This is text message';

$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';

$headers[] = 'From: My site <info@mysite.com>';

mail($to, $subject, $message, implode("\r\n", $headers));

and I want to do this job in Laravel5.8 framework in the future

My PHP version is 7.2.7 and Laravel version I want to use in the future is 5.8

Please help me and I'm really confused



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire