Sending email with PHP mail()
Posted
by
david_85
on Stack Overflow
See other posts from Stack Overflow
or by david_85
Published on 2012-04-12T05:26:51Z
Indexed on
2012/04/12
5:28 UTC
Read the original article
Hit count: 101
I'm trying to send automated emails with mail(). It sends some emails but not all, around 50%. To test I'm using the same email address for all emails, and still only some get delivered.
I'm using localhost XAMPP.
Here's the code:
if($_POST['sendEmail'] == "SEND Email"){
ob_start();
$buffer = str_repeat(" ", 4096); $buffer .= "\r\n some HTML \r\n";
set_time_limit(0);
$noEmails = $last - $first + 1;
echo "Emails sent (of $noEmails):";
for($index = $first; $index <= $last; $index++){
$to = $email["$index"];
$subject = "Hey {$firstName["$index"]}!";
$message = "$emailMessage";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
sleep(1);
mail($to,$subject,$message,$headers);
echo $buffer.$index;
ob_flush();
flush();
}
ob_end_flush();
}
Please give your suggestions.
© Stack Overflow or respective owner