SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Space instead of newline?

    Can anyone please tell me why I am getting spaces instead of newlines in this code where I use \n?

    Code PHP:
    <?php 
    		$mail_recipient = "Jeremywoods@xtra.co.nz";
    		$mail_subject = "Enquiries";
    					$Name = Trim(stripslashes($_REQUEST['Name']));
    					$Email = Trim(stripslashes($_REQUEST['Email']));
    					$Company = Trim(stripslashes($_REQUEST['Company']));
    					$Address = Trim(stripslashes($_REQUEST['Address']));
    					$Phone = Trim(stripslashes($_REQUEST['Phone']));
    					$Comments = Trim(stripslashes($_REQUEST['Comments']));
    		$Body = "";
    					$Body .= $Name. "\n";
    					$Body .= $Email. "\n";
    					$Body .= $Company. "\n";
    					$Body .= $Address. "\n";
    					$Body .= $Phone. "\n";
    					$Body .= $Comments. "\n";
    									$headers .= 'MIME-Version: 1.0' . "\r\n";
    									$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     
    			// send email 
    $success = mail($mail_recipient, $mail_subject, $Body, $headers);
    	if($success==true) {
    	echo "Your mail has been Sent Successfully";}
    	else
    	{echo "Your mail has Not Sent Successfully";}
     
    			?>

  2. #2
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that's because you are sending this mail as html.

    PHP Code:

    <?php
     $headers 
    .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    ?>
    Instead of "newlines" \n use "breakspace" ( <br /> ) or send the mail as text.
    Last edited by FallenJehova; Jun 28, 2007 at 04:44. Reason: Bad [/PHP]

  3. #3
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awsome, thank you for that. I just removed the reference to html and it worked.


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
  •