-2

php auto send mail at time and have setting?

i want create email and save database

at time email auto send to email ex:i setting at 8:00 PM

Send email1 (to,subject1,message1),send email2(to,subject2,message2)....

Because i use database mysql so, i want auto send subject + message if status =0

status =0 is no send, status =1 is old send.

Please help. Thanks.

tranchau
  • 103
  • 7

1 Answers1

0

You would need to use a cron job to visit a page:

0 20 * * * curl http://yourwebsite.com/emailscript.php

^Fires off at the 0 minute, of the 20th hour (8:00pm), of every day, of every week, of every month.

contents of emailscript.php:

$to = "email@email.com";
$subject = "Cron Job HTML email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags and is a test of the cron jobs!</p>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: email@yoursite.com <email@yoursite.com>' . "\r\n";

mail($to,$subject,$message,$headers);
Vigs
  • 1,286
  • 3
  • 13
  • 30