我正在尝试做一个php,将发送电子邮件每60秒从一个收件人
电子邮件。但我不知道该怎么做。
emails.txt:
email1@google.com,
email2@google.com,
email3@google.com
同一条信息将发送给所有3个收件人,但每次发送之间间隔60秒。
<?php>
$file = fopen("emails.txt", "r") or die("Unable to open file!");
//while(!feof($file)){
$line = fgets($file);
$to = $line;
$config['mailtype'] = "html";
$this->email->initialize($config);
$subject = "Subject";
$message = 'This is test message';
$header = "From:TESTE \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
foreach($to as $value) {
$result = mail($value, $subject, $message, $header);
sleep(60);
}
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
fclose($file);
}
</php>