Jump to content

Changing br to \r\n without effecting email output


wright67uk

Recommended Posts

The code below returns the correct results, which are in this case are email addresses.

After each displayed value there is a br eg.  emai1@hotmail.com<br>email2@hotmail.com<br>email3@ etc.

So the quesion is, can i change the below codeing to prevent this.

I have tried changing

$message .= "<br>". $row['email']   to  
$message .= "\n". $row['email'] 

but this results in;

 

Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html

 

so now i changed the line to

$message .= "\r\n". $row['email'] 

and my email displays perfectly.

 

The only problem now is that the email addresses and message are all on one line on screen, is there a way to get each of the returned email addresses to sit on a new line, without it bringing back those br br br's in my email output?

 

mysql_select_db("treesurgery") or die("Unable to select database"); 
$code = $_GET['postcode'];
$message = $_GET['message'];
$emailad = "email@hotmail.co.uk";
$shortcode = substr($code,0,2);
$result = mysql_query("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3")
or die(mysql_error());  
echo "<h2>Business Names:</h2>";                     
while ($row = mysql_fetch_array( $result )) 
{
$message .= "\r\n". $row['email'] ;
}
echo $message; 
mail( "$emailad", "Header","$message" );
echo "<br>" . "Thank you for using our mail form.";

 

 

Thankyou

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.