...

View Full Version : Additional line in mail() sent?



stfc_boy
10-23-2009, 09:02 AM
Hi,

I'm trying to get text out of a mysql (text) field:

http://www.inspireaway.co.uk/body_text.jpg

and assign it to a variable $the_body:



$the_body = stripslashes($body_text);


Now in my script I send $the_body value as an email:



mail("".$email."", "".$the_body."", $message, $headers);


Now this all works fine, but when the email is sent I recieve it and it puts two line spaces between each paragraphs when I want one line break. It appears like so:


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porta, elit in consectetur vulputate.


Just egestas elit, eget varius nulla magna malesuada urna. Nullam a malesuada diam. Nunc et sapien pretium metus venenatis ornare sed in tortor.


Ut aliquet ornare enim vel consequat. Fusce nec neque vel eros congue venenatis. Sed augue elit, gravida sit amet bibendum quis, rutrum ultricies nunc.


Now I presume this is to do with the way I hold this data in mysql? But is there a way in php I can ditch one of the lines sent in the mail without changing anything in mysql?

Thanks

SystemJay
10-23-2009, 12:15 PM
You could edit the body String with such:



str_replace("\n", "", $string);


Note that this removes ALL line brakes, not just one.
Just throwing ideas in the air :)

EDIT:
But then again, you could fix two line brakes like this:



str_replace("\n\n", "\n", $string);


So in this case, it would change two linebrakes into one line brake.
Hope this helps, havent tested it but it cant be far away. If there
is for some reason whitespace between the linebrakes you would
need to add it too ie. "\n \n" or "\n \n" so on..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum