Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an HTML Email

Status
Not open for further replies.

webmigit

Programmer
Aug 3, 2001
2,027
US
Everyone says the below should send html email.. but its not... it sends the html as plain text, I've tried editing/removing/adding.. can't get it to do anything but give me a whole bunch of header info I don't want.

Please help

Tony

Code:
<?php
$to = &quot;thicks@wisernet.com\r\n&quot;;
$subject = &quot;Testing&quot;;
$fc=implode(&quot;&quot;,file(&quot;[URL unfurl="true"]http://www.sierratimes.com/sendalert.txt&quot;));[/URL]
// $fc=strip_tags($fc);
$headers  = &quot;MIME-Version: 1.0\r\n&quot;;
$headers .= &quot;Content-type: text/html; charset=iso-8859-1\r\n&quot;;
mail(&quot;$to&quot;, &quot;$subject&quot;, &quot;<b>$fc</B>&quot;, $headers);
echo($fc)
?>
 
try it without the &quot;\r&quot; symbol

Code:
<?php
$to = &quot;thicks@wisernet.com\n&quot;;
$subject = &quot;Testing&quot;;
$fc=implode(&quot;&quot;,file(&quot;[URL unfurl="true"]http://www.sierratimes.com/sendalert.txt&quot;));[/URL]
// $fc=strip_tags($fc);
$headers  = &quot;MIME-Version: 1.0\n&quot;;
$headers .= &quot;Content-type: text/html; charset=iso-8859-1\n&quot;;
mail(&quot;$to&quot;, &quot;$subject&quot;, &quot;<b>$fc</B>&quot;, $headers);
echo($fc)
?>
 
Hey..

Thanks, but all that did was not show the excess header information which I didn't want it to do anyway...

Any other ideas?
Tony
 
Change
Code:
$headers  = &quot;MIME-Version: 1.0\n&quot;;
$headers .= &quot;Content-type: text/html; charset=iso-8859-1\n&quot;;
to
Code:
$headers  = &quot;MIME-Version: 1.0\r\n&quot;;
$headers .= &quot;Content-type: text/html; charset=iso-8859-1&quot;;
You shouldn't put a newline on the last header, and you should use CR-LF as specified by the SMTP RFC (if your mail server doesn't automatically do it). //Daniel
 
Code:
<?php
$to = &quot;thicks@wisernet.com\n&quot;;
$subject = &quot;Testing&quot;;
$fc=implode(&quot;&quot;,file(&quot;[URL unfurl="true"]http://www.sierratimes.com/sendalert.txt&quot;));[/URL]
// $fc=strip_tags($fc);
$headers  = &quot;MIME-Version: 1.0\r\n&quot;;
$headers .= &quot;Content-type: text/html; charset=iso-8859-1&quot;;
mail(&quot;$to&quot;, &quot;$subject&quot;, &quot;<b>$fc</B>&quot;, $headers);
echo($fc)
?>

Two Questions
One, is it possible to shut off html emails in php, could the host have done this?

Two, Is my problem an unusual problem? I took the recommendations you made and tried it and tried fiddling with it, nothing I came up with worked.

Tony Hicks
 
Your problem is obivous. I can't believe I missed it the first time.
You have a newline on the end of the address:
[tt]$to = &quot;thicks@wisernet.com\n&quot;;[/tt]
Remove it and it should work fine (it does on my server anyway). //Daniel
 
That just added a lot of header information:

Code:
Content-type: text/html; charset=iso-8859-1
Message-Id: <E17opmp-0000HR-00@*****>
From: Nobody <nobody@*****>
Date: Tue, 10 Sep 2002 11:30:55 -0700
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - *****
X-AntiAbuse: Original Domain - *****
X-AntiAbuse: Originator/Caller UID/GID - [99 99] / [99 99]
X-AntiAbuse: Sender Address Domain - *****

The ***** are places where I removed information... How can I get the php version number... maybe there's a flaw in the version?

Tony
 
I'm guessing that the headers are added by the mail server, as a security precaution by the host in case someone sends 1000 emails to the same address or something.
The version can be seen either with phpinfo() or with php_version() (I think, not really sure though). //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top