Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Bold and tabs

  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Bold and tabs

    Hiya

    I am retrieving inputs from a form and then in my php script, I am concatenating these and using them to create the body argument for the "mail" command. I would like text like "EMAIL", "ADDRESS LINE" to be bold and also to have tabs in the email- please can anyone help? The code from the script is as below:

    $name = $_REQUEST[name] ;
    $email = $_REQUEST[email] ;

    $address_1 = $_REQUEST[address_1] ;

    $body = "NAME: $name
    EMAIL: $email\n\n
    ADDRESS LINE 1:\t\t $address_1\n"

    $sent = mail($to, $subject, $body, $headers) ;

    I have already tried \t, but that doesn't seem to put any tabs in.

    Any help would be great
    Starrygirl

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,396
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    I think what you're trying to do, or should do, it use HTML email instead
    of plain text. Most people allow their email clients to view HTML email.

    The PHP script below is an example. If they don't allow HTML emails, it
    will default to text only. But this allows you to format your message.

    Put in your email address ( "to" ) and see what it looks like.
    You'll then have to program in the variables from your form, as this example
    has hard-coded variables (just for testing).

    PHP Code:
    <?
    $from
    ="john@aol.com";
    $from_email=$from;
    $to="williamsmith@comcast.net";
    $subject="This is an email test";
    $name="John Smith";
    $address="123 Elm Street";
    $phone="123-555-1234";

    //redirect.  where to go after sending email (like a thankyou page)
    $redirect="http://www.mysite.com/thankyou.html";

    $mailcontent="
    <table>
    <tr><td><b>Name:</b></td><td>$name</td></tr>
    <tr><td><b>Address:</b></td><td>$address</td></tr>
    <tr><td><b>Phone:</b></td><td>$phone</td></tr>
    <tr><td><b>Email:</b></td><td>$from</td></tr>
    </table>
    "
    ;

                 if (
    strtoupper(substr(PHP_OS,0,3)=='WIN'))
                
    $eol="\r\n";
            elseif (
    strtoupper(substr(PHP_OS,0,3)=='MAC')) 
                
    $eol="\r";
            else
                
    $eol="\n";

         
    // Now append $eol variable with header 
         
    $headers "From: ".stripslashes($from)." <".stripslashes($from_email).">".$eol;

          
    //specify MIME version 1.0
        
    $headers .= "MIME-Version: 1.0".$eol;

        
    //unique boundary
        
    $boundary md5(uniqid(time())); 

        
    //tell e-mail client this e-mail contains//alternate versions
        
    $headers .= "Content-Type: multipart/alternative" .

                   
    "; boundary =".$boundary.$eol;

        
    //message to people with clients who don't understand MIME
        
    $headers .= "This is a MIME encoded message.".$eol;                    

        
    //HTML version of message
        
    $headers .= "--".$boundary.$eol .
        
    "Content-Type: text/html; charset=ISO-8859-1".$eol .
        
    "Content-Transfer-Encoding: 8bit".$eol;            

        
    mail(stripslashes($to), stripslashes($subject), stripslashes($mailcontent), $headers);

    // Go to thankyou page...
    header ("location: $redirect");
            
    ?>

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much ... was wondering if there is an alternative, if I didn't want to use html?

    Thanks
    Starrygirl

  • #4
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,396
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    No alternative that I know of.

    Not all email clients are the same, and there are
    many revisions of various clients like Outlook O/Express.

    Try HTML for a while with various people and see what they think.

    You'll end up liking the flexibility, and if people read their email
    online, you can include graphic images also. People who read their
    email off-line ... of course can't access images.


  •  

    Posting Permissions

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