This is an interesting one - probabely quite obvious to the experienced but...
I have a text file which contains a list of email addresses (email.txt)
I want to send an email to each one of the addresses seperately,
I'm using the following code:
// ** Get the names from the text file *
$fp = fopen("email.txt","r");
while (!feof($fp))
{
$to = fgets($fp, 100);
// ** Email sending details here... **
$msg = "<html><head><title><body>...etc...</html>";
$mailheaders = "From: John Smith <john@smith.com>\n";
$mailheaders .= "Reply-To: sally@smith.com\n";
$mailheaders .= "MIME-Version: 1.0\n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1";
// ** now the actual mail function **
mail($to, 'Subject', $msg, $mailheaders);
echo "E-Mail sent to $to<br>";
}
fclose($fp);
It echos the correct number of email addreses correctly and even sends the last email address on the list the correct HTML email, however, all the others get sent an email but with the actual mailheaders as part of the text. The email starts with:
Subject: Subject
From: John Smith<john@smith.com>
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
<html><head><title>......etc</html>
😕
any ideas????
F.