...

View Full Version : Bold and tabs



starrygirl1980
11-27-2006, 06:25 PM
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

mlseim
11-27-2006, 08:16 PM
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).



<?
$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");

?>

starrygirl1980
11-27-2006, 10:42 PM
Thank you very much ... was wondering if there is an alternative, if I didn't want to use html?

Thanks
Starrygirl

mlseim
11-28-2006, 02:39 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum