SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    email has no line breaks!

    Hello,

    I have a problem with the emails sent with mail().

    They all arrive to the users without linebreaks. I've tried \n but that doesn't work. What is the problem. Server setup?

    Scott

  2. #2
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if this would be a problem, or if it would apply when sending emails, but is your message in double quotes or single quotes?

    eg:
    $message = "blah \n";
    or
    $message = 'blah \n';
    Oh no! the coots are eating my nodes!

  3. #3
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The text is pulled out of a db with a function but as far as I can tell the $message variable is surrounded in double quotes.

    Scott

  4. #4
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you noticed that this forum also has no linebreaks in the emails sent from it?

    Only the excerpt has linebreaks. Here is what I recieved:

    Code:
    Hello scamo,  timnz has just replied to a thread you have subscribed to entitled - email has no line breaks! - in the PHP and MySQL forum of SitePoint Community Forums.  Excerpt: Not sure if this would be a problem, or if it would apply when sending emails, but is your message in double quotes or single quotes?
    
    eg:
    $message = "blah \n";
    or
    $message = 'blah \n';  This thread is located at: http://sitepointforums.com/showthrea...4&goto=newpost  There may be other replies also, but you will not receive any more notifications until you visit the board again.  Yours, SitePoint Community Forums team   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unsubscription information:  To unsubscribe from this thread, please visit this page: http://sitepointforums.com/member2.p...threadid=31694  To unsubscribe from ALL threads, please visit this page: http://sitepointforums.com/member2.p...type=allthread
    See what I mean?

    Scott
    Last edited by scamo; Aug 20, 2001 at 03:31.

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Trya \r\n where you want the line breaks.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Um, the emails from this forum have always worked perfectly for me...maybe something's wrong with your email client. They've always had line breaks for me.

  7. #7
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You must do:

    $text = str_replace("\n", "\r\n", $text);

  8. #8
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you really have to do that? Because the emails I have sent myself through one of my email scripts, worked perfectly when I had like:
    $str = "Hello\nThis is on a newline";
    Oh no! the coots are eating my nodes!

  9. #9
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think we have come closer to an answer. My colleague found out something. You can determine the content-type in the header of your email when using the mail() function. Something like this:
    Code:
    $message = "The following email includes a formatted ASCII table\n";
    $message .= "Day \t\tMonth \t\tYear\n";
    $message .= "3rd \t\tAug \t\t1970\n";
    $message .= "17rd\t\tAug \t\t1973\n";
    $headers = "Content-Type: text/html; charset=iso-8859-1\n";
    mail("$address","Teste mail() Funktion",$message,$headers);
    Of course for non-html emails the line '$headers = "Content-Type: text/html; blah blah', should have text/plain written in it.

    We'll see if that'll do the trick!

    Thanx everyone for your input.

    Scott


Bookmarks

Posting Permissions

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