SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Why are my mail() emails indenting each paragraph?

    When I receive the following email in my inbox, the word Dear is on the left. All other paragraphs are indented. Normally I put the whole message in double quotes and I don't have this problem, but I'm trying to keep my code more organized by using proper indentation. Unfortunately it's affecting the output of my emails. Can anyone point me in the right direction on this one?

    Thanks!

    Code:
    <?php
    
    $formFirstName = "Robert";
    
    
    		// Indenting this code for organizational purposes
    						
    		$text = 'Dear ' . $formFirstName . ',
    		
    		We need you to confirm your registration. This helps to prevent fraudulent spambot entries from entering our database.  To finalize your account, and be eligible for posting your own testimonials, please click on the following link.
    		
    		Here is a new paragraph with the users  ' . $formFirstName . '.
    		
    		Thank you';
    
    
    
    
    $subject = "Confirm your registration $formFirstName";
    $text = wordwrap($text,70);
    		
    $headers = "From: Oil-Testimonials.com <support@oil-testimonials.com>\r\n";
    $headers .= "Reply-To: support@oil-testimonials.com\r\n";
    $headers .= "Return-Path: support@oil-testimonials.com\r\n";
    		
    mail("robert@recordaudio.net", $subject, $text, $headers);
    
    
    print ("Email has been sent.");
    ?>
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,872
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Remove the indents from within the data itself.

    Code:
    <?php
    
    $formFirstName = "Robert";
    
    
    		// Indenting this code for organizational purposes
    						
    		$text = 'Dear ' . $formFirstName . ',
    		
    We need you to confirm your registration. This helps to prevent fraudulent spambot entries from entering our database.  To finalize your account, and be eligible for posting your own testimonials, please click on the following link.
    		
    Here is a new paragraph with the users  ' . $formFirstName . '.
    		
    Thank you';
    
    
    
    
    $subject = "Confirm your registration $formFirstName";
    $text = wordwrap($text,70);
    		
    $headers = "From: Oil-Testimonials.com <support@oil-testimonials.com>\r\n";
    $headers .= "Reply-To: support@oil-testimonials.com\r\n";
    $headers .= "Return-Path: support@oil-testimonials.com\r\n";
    		
    mail("robert@recordaudio.net", $subject, $text, $headers);
    
    
    print ("Email has been sent.");
    ?>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You do have to make sure those spaces are not in the string. Here's another way to do it while keeping the indention of the code. Note that "\n" is a new line and I'm just concatenating the pieces together.

    PHP Code:
          $text "Dear {$formFirstName},\n\n" .
          
    "We need you to confirm your registration. This helps to prevent fraudulent spambot entries from entering our database.  To finalize your account, and be eligible for posting your own testimonials, please click on the following link.\n\n" .
          
    "Here is a new paragraph with the users  {$formFirstName}.\n\n" .
          
    'Thank you'
    - Robert


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
  •