All
some help would be welcome. I'm having troubles with this simple email script.
the idea: would like to make a mailing from a form. This works just fine. I'm having troubles with the mailing it self.
What i posted here: I edited my code to try without concatenating strings (*$_Post varible within xml). This however doesn't work eitherway.
tests:
all variables get set properly (tested with echo's so I cut them out to save you the reading :-))
connection gets established just fine
All email adresses from the database pass by just fine. (also by echo :-))
I'm thinking semantic error but can't find the problem. Can anyone help me? :'(
<?php
//make connection with database
$con = mysql_connect("XXXXXXXXX","XXXXXXXXXX","XXXXXXXX");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dejuistestudiek", $con);
//select all emails from mailing table
if($con){
$sql = "SELECT * FROM mailing";
$result = mysql_query($sql);
//prepare text for html mail
$text = trim($_POST['TEXT']);
$text = nl2br($text);
$text = stripslashes($text);
if($result){
while($row = mysql_fetch_array($result)){
// single recipient
$to = $row['email'];
// subject
$subject = 'StuWay - Nieuwsbrief';
// message
$message = '<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Do-Not-Reply@dejuistestudiekeuze.be' . "\r\n";
// Mail it
$bool = mail($to, $subject, $message, $headers);
}
}
}
?>