我每天必须在php中每隔24小时向学生发送3封自动电子邮件作为通知电子邮件。
您可以使用cronjob来完成这项工作。
我假设您使用的是cpanel服务器。首先创建一个php脚本来发送邮件。这是一个非常基本的问题。如果你需要,你可以使用下面的例子,我从php.net 中提取
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "'r'n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "'r'n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "'r'n";
$headers .= 'Cc: birthdayarchive@example.com' . "'r'n";
$headers .= 'Bcc: birthdaycheck@example.com' . "'r'n";
// Mail it
mail($to, $subject, $message, $headers);
?>
要设置cron作业,您不需要任何编码。请关注此视频或在谷歌中搜索"如何在cpanel中设置cron"。
http://www.youtube.com/watch?v=E_UAp80UrPY