OK - bit of a newbie to all this php lark...
I've got a form which sends mail to my mailing list (all working no problems). The only issue i have is that line breaks in the text area arn't carried through to the email. I've tried '\n' and 'nl2br()' wont work because it's plain text.
The form is:
<form name="mail_all_members" method="post" action="mail_all_members_script.php">
<p align="center"><font face="Verdana, Arial, Times New Roman" size="2">Subject:
<input type="text" name="subject" value="">
</font></p>
<p align="center"><font face="Verdana, Arial, Times New Roman" size="2">Message:<br>
<textarea name="message" cols="50" rows="7" wrap="PHYSICAL"></textarea>
</font></p>
<p align="center">
<input type="submit" name="Submit" value="Send">
</p>
</form>
And the script is:
<?php
//creates your newsletter an sends it.
if (($subject == "") || ($message == ""))
{
header("Location : mail_all_members.php");
exit;
}
else
{
//make a connection
$connection = mysql_connect("servername" , "username" , "password")
or die("cannot make connection");
//select the database
$db = mysql_select_db("databasename" , $connection)
or die("cannot find database");
$sql_query = "SELECT email_address FROM users";
$result = mysql_query($sql_query) or die("cannot execute query");
$header = "From: members@sitename.com\n"
. "MIME-Vesion: 1.0\n"
. "Content-Type: text/plain; charset='iso-8859-1'\n"
. "Content-Transfer-Encoding: 7bit\n"
. "Return-Path: members@sitename.com\n"
. "Errors-To: members@sitename.com\n";
//loop through rows
while ($row = mysql_fetch_array($result))
{
$address = $row[0];
//mail function requires email address($address)
//The subject($subject) , the message ($body) and
//the $header info
mail($address ,$subject , $message , $header);
//display a message confirming email has been sent
echo ("newsletter sent to : $address<br>");
}
echo ("Completed sending emails");
}
?>
Thanks in advance