Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts

    Additional line in mail() sent?

    Hi,

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



    and assign it to a variable $the_body:

    PHP Code:
    $the_body =  stripslashes($body_text); 
    Now in my script I send $the_body value as an email:

    PHP Code:
      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

  • #2
    New Coder
    Join Date
    Mar 2009
    Posts
    62
    Thanks
    19
    Thanked 1 Time in 1 Post
    You could edit the body String with such:

    PHP Code:
    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:

    PHP Code:
    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..
    Last edited by SystemJay; 10-23-2009 at 01:34 PM.

  • Users who have thanked SystemJay for this post:

    stfc_boy (10-23-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •