Inserting <br /> in HTML email

Discussion in 'PHP' started by enchance, Nov 16, 2008.

  1. #1
    I'm trying to send an HTML email (which works, btw), but whenever the message has a newline by presenting ENTER on the keyboard, the email doesn't show it. Instead it just displays it in 1 whole line. How do I add the <br /> everytime the user presses ENTER on their message?
     
    enchance, Nov 16, 2008 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    use nl2br() function. Look in the PHP manual on how to use it!
     
    rohan_shenoy, Nov 16, 2008 IP
  3. mdvasanth86

    mdvasanth86 Notable Member

    Messages:
    3,869
    Likes Received:
    285
    Best Answers:
    0
    Trophy Points:
    230
    #3
    hmmm.... may be just try the <br> (with out the /)tag .. older html tag... may work...
    else, you can try the <pre> tag .... it will definitely solve your problem....
    Hope it helps....

    ciao!!
     
    mdvasanth86, Nov 16, 2008 IP
  4. enchance

    enchance Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It worked! Thanks!
     
    enchance, Nov 16, 2008 IP
  5. enchance

    enchance Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Btw, is it possible for me to change the the name which comes out in the "from" field?
     
    enchance, Nov 16, 2008 IP
  6. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #6
    You mean "ABC XYZ <abc@xyz.com>"
    Look up the mail() function in the php manual. Yes, you can do it.
     
    rohan_shenoy, Nov 16, 2008 IP
  7. Napoleon

    Napoleon Peon

    Messages:
    732
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Using \n instead of <br /> might work too
     
    Napoleon, Nov 16, 2008 IP
  8. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #8
    Simply wrapping the text in <pre></pre> which stands for "pre-formatted text" works much better.

    <pre>
    This
    is
    the
    contents
    </pre>
    Code (markup):
     
    joebert, Nov 16, 2008 IP
  9. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #9
    If you want to change the name in the to/from field, simply use e.g. "from: Your name <your@email.com>"
     
    elias_sorensen, Nov 17, 2008 IP