|
Posted by steve on 06/30/05 07:30
in-line
"paul" <paul@not.net> wrote in message
news:k5idnUKUmuaqrF7fRVn-rg@speakeasy.net...
| Is there a trick to get an email formatted so the <html> tags don't
| show? I sometimes get html emails but mozilla doesn't just spit out html
| tags like this.
|
| I tried simply adding <html> content </html> with no effect. Do I need
| to add more specific headers?
|
| I wouldn't mind printing in tabbed plain text rows but that's not easy
| to translate from the html table which exists.
here's an example of a multi-part/related email w/ text or html. i hth...i'd
make an html page that displays as you desire it to, then i'd put that html
into this code...sorry for the text-wrapping you'll have to contend with.
----------------
function mailErrors($errors)
{
if (!is_array($errors)){ return; }
if (count($errors) == 0){ return; }
global $emailNotify;
global $siteCompanyLogo;
$file = fopen($siteCompanyLogo, 'r');
$image = fread($file, filesize($siteCompanyLogo));
$image = chunk_split(base64_encode($image));
$boundry = '----=' . md5(uniqid(rand()));
$related = '----=' . md5(uniqid(rand()));
// the only important thing to note here is how the embedded
// image is referenced by the html in this email...
// see the last few lines before the "ignore" comment below.
$html = '
<html>
<style>
body
{
font-family : arial, tahoma, verdana;
font-size : 8pt;
}
.record
{
font-size : 8pt;
margin-left : 2px;
margin-right : 2px;
}
.record.detail
{
background-color : ghostwhite;
font-size : 8pt;
font-weight : normal;
margin-right : 2px;
min-width : 50px;
max-width : 100px;
overflow-X : hidden;
padding-left : 2px;
padding-right : 2px;
text-align : left;
whitespace : nowrap;
}
</style>
<body>
<h2 style="float:left;">Automation Upload Errors</h2>
<img alt="Company Logo" border="0px" src="cid:logo"
style="float:right;">
<br>
<br>
<br>
<br clear="all">
';
$text = '';
// you may begin to ignore dynamic html generation here!
foreach ($errors as $header => $properties)
{
$html .= '<table border="0px" cellpadding="0px" cellspacing="0px">' .
"\r\n";
$html .= ' <tr class="record">' .
"\r\n";
if (!is_array($properties['COLUMNS'])){ $properties['COLUMNS'] =
array(); }
if (!is_array($properties['LINES'])){ $properties['LINES'] =
array(); }
foreach ($properties['COLUMNS'] as $column => $value)
{
$html .= ' <td class="detail"
style="background-color:lightsteelblue; font-weight:bold;">' . $column .
'</td>' . "\r\n";
$text .= $column . "\t";
}
$text .= "\r\n";
$html .= ' </tr>' . "\r\n";
$html .= ' <tr class="record">' . "\r\n";
foreach ($properties['COLUMNS'] as $column => $value)
{
$html .= ' <td class="detail"
style="background-color:lightsteelblue;">' . $value . '</td>' . "\r\n";
$text .= $value . "\t";
}
$text .= "\r\n\r\n" . $errors[$header]['ERRORS'] . "\r\n";
$html .= ' </tr>'
.. "\r\n";
$html .= ' <tr class="record">'
.. "\r\n";
$html .= ' <td class="detail" colspan="19"
style="background-color:yellow;">' . "\r\n";
$html .= str_replace("\r\n", "<br>", $errors[$header]['ERRORS'])
.. "\r\n";
$html .= ' </td>'
.. "\r\n";
$html .= ' </tr>'
.. "\r\n";
$html .= '</table>'
.. "\r\n";
$html .= '<table border="0px" cellpadding="0px" cellspacing="0px">'
.. "\r\n";
$html .= ' <tr class="record">'
.. "\r\n";
foreach ($properties['LINES'] as $repairs => $repair)
{
foreach ($repair['COLUMNS'] as $column => $value)
{
$html .= ' <td class="detail" style="font-weight:bold;">' .
$column . '</td>' . "\r\n";
$text .= $column . "\t";
}
break;
}
$text .= "\r\n";
$html .= ' </tr>' . "\r\n";
$html .= ' <tr class="record">' . "\r\n";
foreach ($properties['LINES'] as $repairs => $repair)
{
foreach ($repair['COLUMNS'] as $column => $value)
{
$html .= ' <td class="detail">' . $value . '</td>' . "\r\n";
$text .= $value . "\t";
}
$text .= "\r\n\r\n" . $repair['ERRORS'] . "\r\n";
$html .= ' </tr>'
.. "\r\n";
$html .= ' <tr class="record">'
.. "\r\n";
$html .= ' <td class="detail" colspan="19"
style="background-color:yellow;">' . "\r\n";
$html .= str_replace("\r\n", "<br>", $repair['ERRORS'])
.. "\r\n";
$html .= ' </td>'
.. "\r\n";
$html .= ' </tr>'
.. "\r\n";
$html .= '</table>'
.. "\r\n";
}
$html .= '<br><br>'
.. "\r\n";
}
$html .= "
</body>
</html>
";
// ok, start paying attention again...
$mail = "MIME-Version: 1.0\r\n";
$mail .= "FROM: Automated Email <someEmailAccount@noWhere.com>\r\n";
$mail .= "TO: " . $emailNotify['TO'] . "\r\n";
$mail .= "CC: " . $emailNotify['CC'] . "\r\n";
$mail .= "BCC: " . $emailNotify['BCC'] . "\r\n";
$mail .= "Subject: Automation Upload Error(s)\r\n";
$mail .= "Content-Type: multipart/related;
boundary=\"$related\"\r\n\r\n\r\n";
$mail .= "--$related\r\n";
$mail .= "Content-Type: multipart/alternative;
boundary=\"$boundry\"\r\n\r\n\r\n";
$mail .= "--$boundry\r\n";
$mail .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$mail .= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$mail .= $text . "\r\n\r\n";
$mail .= "--$boundry\r\n";
$mail .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$mail .= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$mail .= $html . "\r\n\r\n";
$mail .= "--$boundry--\r\n\r\n";
$mail .= "--$related\r\n";
$mail .= "Content-Type: image/jpeg\r\n";
$mail .= "Content-ID: logo\r\n";
$mail .= "Content-Disposition: attachment; filename=\"logo.jpg\"\r\n";
$mail .= "Content-Transfer-Encoding: base64\r\n\r\n";
$mail .= $image . "\r\n\r\n";
$mail .= "--$related--\r\n\r\n";
$mail .= "-- End --\r\n";
iisMail($mail);
}
Navigation:
[Reply to this message]
|