Forum Moderators: coopster

Message Too Old, No Replies

Problem sending HTML mail with mail(). (Bad formatting it says)

Using jetboy_70's script but it won't work, says bad RFC2822 formatting..:?

         

rem_sr

11:12 am on Jun 19, 2004 (gmt 0)



I'm trying to send a HTML-mail with mail(), and I'm using the function presented by jetboy_70 which can be seen here: [webmasterworld.com...]

The script is working on some clients but not on everyone. The fault I get from the headers in the sent mails is:
" X-Mail-Format-Warning: Bad RFC2822 header formatting "

I'm kinda new to this stuff with multipart-MIME emails, and would appreciate some help.

cheers,

inwebsys

8:18 pm on Jun 19, 2004 (gmt 0)

10+ Year Member



I've had good luck using something similar to this:

<?php
########################################################################
# Copyright © 2001 Wanja Hemmerich #
# First version published May 2001 - This version August 2001 #
########################################################################
# COPYRIGHT NOTICE #
# Copyright 2001 Wanja Hemmerich. All rights reserved. #
# #
# This program may be used and modified, as long as this copyright #
# notice stays intact. #
# #
# Wanja Hemmerich is not responsible for damage, which is possibly #
# caused by his program. #
# #
# This program code may not be sold, nor auctioneered, nor be used in #
# any other commercial way in order to make money. #
# #
# This Programm may not be distributed to download neither by #
# Internet, nor by another medium. #
########################################################################
# By using this programm, you agree with these conditions. #
# #
########################################################################
# The text above must be kept intact under all circumstances. #
########################################################################

function sendmsg($subject, $text, $from, $file, $type, $rname) {
$content = fread(fopen($file,"r"),filesize($file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = $rname;

$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";

$header .= "--$uid\n";
$header .= "Content-Type: text/html\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";

$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$name\"\n";

$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= "$content\n";

$header .= "--$uid--";

mail('you@yourdomain.com', $subject, "", $header);

return true;
}

#
#End of copyrighted code
#

function email_request() {
$sent_date = date("F j, Y, g:i a", strtotime($row["date"]));
$subj = "Your Subject";
$txt = "<b>Your HTML text here:</b><br>\n\n";
$txt .= "----------------------------------------------<br><br>\n\n";
$txt .= "More HTML Text Here.<Br><br>\n";
$txt .= "More HTML Text Here.<Br><br>\n";
$txt .= "More HTML Text Here.<br>\n";
sendmsg($subj, $txt, 'no-reply@yourdomain.com');
}

?>