Jump to content

mass emailing users not cleaning strings


graham23s

Recommended Posts

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 = "admin@.com";
 $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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.