SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2008
    Location
    Plymouth, United Kingdon
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make \n\n into line break through mail() ?

    How to make \n\n into line break through mail() ?

    This is my code so far...

    Code:
    $to_email = 'name@yahoo.co.uk';
    		
    		$from_name = $row_info_sender['mai_name'];
    		
    		$host_email = "info@site.com";
    		
    		$subject = "My Blog: You have a comment!";
    		
    		$header = "from: www.site.com/blog/ <$host_email>";
    		
    		$message = "$from_name has just sent a comment on your post with the title of '$post_title'.\r\n\n";
    		$message.= "'$cmt_content'\r\n\n";
    		$message.= "thank you,\r\n";
    		$message.= "the server\r\n";
    		
    		$sentmail = mail($to_email,$subject,$message,$header);
    result:

    XXX has just sent a comment on your post with the title of 'Project 1'.

    'Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\nLorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.'

    thank you,
    the server

    but what I wish to receive in my email is this below actually,

    'Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.'

    Many thanks,
    Lau

  2. #2
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Try this instead:
    PHP Code:
    $to_email 'name@yahoo.co.uk';
            
            
    $from_name $row_info_sender['mai_name'];
            
            
    $host_email "info@site.com";
            
            
    $subject "My Blog: You have a comment!";
            
            
    $header "from: www.site.com/blog/ <$host_email>";
            
            
    $message .= $from_name" has just sent a comment on your post with the title of " $post_title "

            " 
    $cmt_content "

            thank you,
            the server"
    ;
            
            
    $sentmail mail($to_email,$subject,$message,$header); 
    You only need to include '\r\n' in the headers and not inside the message area for the email.

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2008
    Location
    Plymouth, United Kingdon
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spence_noodle View Post
    Try this instead:
    PHP Code:
    $to_email 'name@yahoo.co.uk';
            
            
    $from_name $row_info_sender['mai_name'];
            
            
    $host_email "info@site.com";
            
            
    $subject "My Blog: You have a comment!";
            
            
    $header "from: www.site.com/blog/ <$host_email>";
            
            
    $message .= $from_name" has just sent a comment on your post with the title of " $post_title "

            " 
    $cmt_content "

            thank you,
            the server"
    ;
            
            
    $sentmail mail($to_email,$subject,$message,$header); 
    You only need to include '\r\n' in the headers and not inside the message area for the email.
    hi thanks. i jst tried. but its still the same if the user inputs a line break in the form...



    HTML Code:
    xxx has just sent a comment on your post with the title of Project 1
    
            Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.[COLOR="Red"]\n\n[/COLOR]Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    
            thank you,
            the server

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My guess is you are modifying the value of $cmt_content in your code, and causing this problem.


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
  •