PHP 5.05
MSSQL 8.0
There seems to be a problem with variables in php code being send to a email via a .bat file wich executes at least once a day. In the php code:
<?php
include_once("C:\automailtest\config.php");
$testtable = "";
$select = "SELECT testnaam FROM testtable";
$query = mssql_query($select);
while ($list = mssql_fetch_object($query)) {
$testtable .= htmlentities($list->testnaam);
}
echo "$testtable<br>";
$variabele = "$testtable";
$mailto = "mail@mail.nl";
$bcc = "mail2@mail2.nl";
$mailfrom = "mailfrom@mail.nl";
$onderwerp = "Test gekke tekens";
$mail_extra = "MIME-Version: 1.0\r\n";
$mail_extra .= "Content-type: text/html; charset=iso8859-1\r\n";
$mail_extra .= "Content-Transfer-Encoding: 8bit\r\n";
$mail_extra .= "From: mailer <".$mailfrom."> \r\n";
$mail_extra .= "Reply-To: <mailreply@mail.nl> \r\n";
$mail_extra .= "X-Priority: 1\r\n";
$mail_extra .= "Date: ".date ("D, j M Y H:i:s 0")."\r\n";
mail($mailto,$onderwerp,$variabele,$mail_extra);
?>
In the database there are the following names: tést,tèst and tëst. They will be send via email when the .bat file executes the php code above.
.bat file:
The problem is when this all is executed, I get as output in the email the following:
t‰st t‚sttŠsttest. In the cmd it is showed correctly like tést, tèst and tëst. When the php script is activated in the localhost via Internet Explorer the problem doesnt occur. But if the .bat file is used then the problem occurs. Is there any code or solution for this, to receive the emails correctly? (Note: this only occurs when the required info from the database is a variable in the php script above, for instance: $testtable or $testname).
It is the meaning to use the .bat file, because in the wwwroot is not a safespot. It must be outside the wwwroot for security reasons.
Thanks in advance.
P1m0s