Hi guys, I am new here and also in php.
I'm trying to send an email to a list of recipients stored in a text file. The text file contains for example the following:
User1 <user1@hisserver.com>, User2 <user2@hisserver.com>, .... etc., etc.
The problem is that at registration some recipients have added quotes or accents to their display names, now having something like this:
User1 <user1@hisserver.com>, User2 "the user" accéntedlastname <user2@hisserver.com>, ... etc., etc.
And when I receive the mail in some of my accounts I get the following advise
X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char EF hex) in message header 'To': To: \357\273\277User1 <user1...
Also the to: field shows some strange characters before the first name:
To: User1 <user1..
My specific question is below the following code wich is the one I use to send the email....
<?php
$filename= 'usersfile.txt';
$file = fopen($filename, "r" );
$recipients = fread($file, filesize($filename));
fclose($file);
$to = $recipients;
$title = "The title";
$from = "ME <me@myserver.com>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: ".$from."\r\n";
$headers .= "Reply-To: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$message = "Some message";
mail($to, $title, $message, $headers);
?>
So, Do I need to make some encoding of the text stored in the txt file, i.e the recipients variable? Is that the problem?
Any help would be great Thanks!!!.
Demian