You are here: Re: mail() sending in html format (or not) « All PHP « IT news, forums, messages
Re: mail() sending in html format (or not)

Posted by paul on 06/30/05 20:07

steve wrote:

> look at the examples found on php.net for the mail() function...you'll need
> to look at the examples that show sending headers...that should get you the
> rest of the way.


Ah, now I get it.

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";

mail($toaddress, $subject, $message, $headers);

So I'll need to separate headers and message. I'm not sure how it would
reassemble that though as multi-part. Maybe if I just did a simpler html
only content with one header.


>
> if you have access to you smtp server's pick up directory, i'd recommend
> just writing directly to it with the output.

I'll check. I'm not sure how this would help though.


> imho, php has always had weak
> support for sending email...especially where authentication is concerned.
> this approach takes a lot of guess work out of the picture. at this point,
> you be troubleshooting your own pertanent code...get that working and then
> you could play around with how you want/should be sending the mail based on
> other constraints you may be under.

Well, I tried it with just one header and I think it's working. Mozilla
doesn't really show the html styling but I think that's just following
the default display without adding colors & such. When I reply, it shows
up as an html table.

For the record, this is what I used (very bare bones):

<?

function html_mail()
{
global $emailTo;
global $emailCC;
$html = '
<html>
<style>
</style>
<body>
';

$html .= '<table>';
$html .= '<tr><td>';
$html .= "column 1";
$html .= '</td>'
. "\r\n";
$html .= '<td>';
$html .= "column 2";
$html .= '</td></tr></table>'
. "\r\n";
$html .= "testing, does the above appear as a table to you
or plain text?
</body>
</html>
";
$mail = "MIME-Version: 1.0\r\n";
$mail .= "FROM: Automated Email <info@x.com>\r\n";
$mail .= "Subject: Triteleia Order Confirmation \r\n";
$mail .= "Content-Type: text/html; charset=us-ascii\r\n";
$mail .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
mail($emailTo, "", $html, $mail);
}
$emailTo = "info@x.com";
html_mail()
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация