Page 1 of 1
PHP supported HTML tags and E-mail
Posted: Sun Mar 30, 2003 4:28 pm
by Sleeve
Hello,
I'm trying to send an html formatted e-mail via PHP and have run into some problems. I haven't found much on the internet about which tags are supported. My hope was that I could send an HTML formatted e-mail with PHP that is as rich as any web page, complete with CSS styles, layout tables, images and text formatting of my choice.
Is this the case? If so, can someone direct me to a reference or lend me some clarification?
Thanks in advance.
Sleeve
Posted: Sun Mar 30, 2003 4:34 pm
by volka
the mail client decides how it treats the mail not the server-side php-script.
So for example in outlook express the internet explorer engine is used to display html-mail, in mozilla the gecko engine ...and so on. Some security settings might be in effect but besides that it's just another html-document to display

Posted: Sun Mar 30, 2003 4:42 pm
by Sleeve
thanks for the reply Volka
That is exactly what I thought too, but when I debug the script I made, I get errors. Here is an example script:
Code: Select all
<? $to = "$sendTo"; $subject = "Important Message";
// your message is now in HTML
$message = "
<html>
<head>
<title>message</title>
</head>
<body>
vaiables and so fourth
</body>
</html>
";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: You <you@you.com>\r\n";
$headers .= "Cc: notyou@you.com\r\n";
$headers .= "Reply-To: $s_name <$s_mail>\n";
$headers .= "X-Mailer: PHP/" . phpversion() . "\n";
$headers .= "X-Priority: 1";
mail("$to", "$subject", "$msg", "$headers");
echo "finished!";
?>
If I use any HTML tags in the body such as:
Code: Select all
<tr>
<td width="725" height="21"> </td>
</tr>
I get errors when debugging and the script doesn't work.
Any thoughts on this?
Posted: Sun Mar 30, 2003 4:44 pm
by volka
I get errors
something specific?
but probably you have problems with nested "s in a double-quoted string literal.
Take a look at the colors the higlighter uses here
Code: Select all
// this produces errors
$message = "
...
<td width="725" height="21"> </td>
...";
Code: Select all
// escaping "s within the literal
$message = "
...
<td width="725" height="21"> </td>
...";
Code: Select all
// using single-quoted literal (no variable substitution)
$message = '
...
<td width="725" height="21"> </td>
...';
Posted: Sun Mar 30, 2003 4:45 pm
by Sleeve
I get this:
Parse error: parse error, unexpected T_LNUMBER in c:\inetpub\wwwroot\call_form.php on line 10
Posted: Sun Mar 30, 2003 4:49 pm
by volka
ooops, I was too slow. take a look at my last post ....and
http://www.php.net/manual/en/language.types.string.php
Posted: Sun Mar 30, 2003 4:55 pm
by Sleeve
all I can say is...Niiiice. You da man!