I am working to get more personalised with my clients by mail. Everything works fine with the code but when i do some test mails, Only the last email address of my client list will be displayed in the inbox.
E.g. My client mailing list is 100+ email addresses and when I mail them, all of them will see the mail address on the last line in my mailing list instead of theirs.
See
<p>Dear '.$clientmail.', </p>
and
$address = file('MUgWgJJE9m7FHh4TFrLHf6YzE.txt', FILE_IGNORE_NEW_LINES);
foreach ($address as $clientmail) {
$mail_sent = @mail($clientmail);
}
I'm working to fix this problem for a good few hours, but can't.. If someone can fix this that would be highly appreciated.
Here is full code to give you more insight.
<?php
// Turn off output buffering
ini_set('output_buffering', 'on');
// Turn off PHP output compression
ini_set('zlib.output_compression', false);
//Flush (send) the output buffer and turn off output buffering
//ob_end_flush();
while (@ob_end_flush());
// Implicitly flush the buffer(s)
ini_set('implicit_flush', true);
ob_implicit_flush(true);
flush();
/// Now start the program output
$subject = 'subject here';
$headers = "From: mail <mail @mail.com>
" .
"Reply-To: mail <mail @mail.com>
" .
"MIME-Version: 1.0
" . "Content-Type: text/html; charset=iso-8859-1";
$address = file('MUgWgJJE9m7FHh4TFrLHf6YzE.txt', FILE_IGNORE_NEW_LINES);
foreach ($address as $clientmail) {
$mail_sent = @mail($clientmail);
}
$template = file_get_contents("template/template.png");
$message = '
<html>
<head>
<title></title>
</head>
<body>
<p>Dear '.$clientmail.', </p>
<strong>rest of content</strong>
<p>'.$template.'</p>
</body>
</html>
';
$emails = file('MUgWgJJE9m7FHh4TFrLHf6YzE.txt', FILE_IGNORE_NEW_LINES);
$x = 1;
foreach ($emails as $email) {
$mail_sent = @mail($email, $subject, $message, $headers, '-f mail@mail.com');
echo $mail_sent ?
$x . '. Mail send to: ' . $email . ' | ' . '<b><font color=green> Successfully Sended!</font><font color=lime> ✓ </font></b>' . '<br/>' :
$x . '. Mail send to: ' . $email . ' | ' . '<b><font color=red> Error 02931: Contact To Fix Issue</font></b>' . '<br/>';
$x++;
}
ob_end_flush();
?>