'PHP Mail recipients from file and interval between messages
I am trying to make a php that will send email every 60 seconds to a recipient from emails.txt but I am not sure how to make this right.
emails.txt:
[email protected],
[email protected],
[email protected]
And the same message would be delivered to all 3 recipients, but 60 seconds between every message sent.
<?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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|