graham23s Posted July 19, 2007 Share Posted July 19, 2007 Hi Guys, when i mass email users from my site the function that cleans all the string doesn't seem to be working for example Hi There comes out as: \r\nHi \r\nThere it works on every other page but not this one code is: <?php // mass pm.../////////////////////////////////////////////////////////////////////// if(isset($_POST['submit'])) { ## mass email ###################################################################### $query = "SELECT email,username FROM `membership`"; $result = mysql_query($query) or die (mysql_error()); ## loop through the emails ######################################################### while($row = mysql_fetch_array($result)) { $members_email = $row['email']; $username = $row['username']; $message = CleanPosts($_POST['message'], 1); ## the vars ######################################################################## $to = $members_email; $subject = "Mass E-Mail From"; $from = "[email protected]"; $body = "Hi, <b>$username</b>"; $body .="<br /><br />"; $body .="$message<br /><br />"; $body .="Regards www..com"; $headers = "MIME-Version: 1.0\r\n"; $headers = "From: <$from>\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $mail_sent = mail($to,$subject,$body,$headers); } ## if emails went ok ############################################################### if($mail_sent) { echo '<br /><b>Mass E-Mails Were Successfully Sent!</b><br /><br />'; } else { echo '<br /><b><font color="red">Error: </font>Sorry There Was An Error Sending The Mass E-Mails Please Try Again!</b><br /><br />'; } } // who is the admin...////////////////////////////////////////////////////////////// $query3 = "SELECT * FROM `membership` WHERE `username`='$member'"; $result3 = mysql_query($query3); $row = mysql_fetch_array($result3); // admins id...///////////////////////////////////////////////////////////////////// $admins_id = $row['id']; // make the form...////////////////////////////////////////////////////////////////. echo '<br /> <table width="500" border="1" bordercolor="#000000" cellspacing="0" cellpadding="4" /> <form action="'.$_SERVER['PHP_SELF'].'" method="POST" /> <tr> <td align="center" bgcolor="#004E98" /><font color="#ffffff"><b>Send A Mass E-Mail To All Users</b></font></b></td> </tr> <tr> <td align="center"><textarea name="message" cols="40" rows="15"></textarea></td> </tr> <tr> <td bgcolor="#004E98" align="right" colspan="2"><input type="submit" name="submit" value="Send Mass E-Mails >>>" /> </td> </table><br />'; ?> not sure what the problem is the function is being called fine but its not getting rid of the the \r\n's thanks for any help guys Graham Link to comment https://forums.phpfreaks.com/topic/60865-mass-emailing-users-not-cleaning-strings/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.