Hi Folks,
I wonder if anyone can find the problem. I generate a multipar/mixed attachement, everything looks nice, but the Mailer doesn't recognise it. I bet there it is something wrong with the Formating. Anyone got a clue what might be wrong ? The Mail is not recognised as a Multipart/mixed - but shown as a plain text-Mail.
Here is what the system generates:
From: smurphy@solsys.org
Reply-To: smurphy@solsys.org
X-Mailer: PHP/4.0.4pl1
Content-Type: multipart/mixed;
boundary="------=_NextPart_POSTCARD_MESSAGE_TAG_5_63"
Date: Mon, 04 Mar 2002 10:04:46
Message-ID: <Stargate04032002100446smurphy@solsys.org>
MIME-Version: 1.0
This is a multi-part message in MIME format.
------=_NextPart_POSTCARD_MESSAGE_TAG_5_63
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
A view from the Top of the Ski-Region near la Lenk.
--
This message was sent to you through the Image gallery at STARGATE
URL: http://web.solsys.org
Please notify errors to smurphy@solsys.org
------=_NextPart_POSTCARD_MESSAGE_TAG_5_63
Content-Type: image/jpeg;
name="imgp0313.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="imgp0313.jpg"
VGhpcyBpcyBzdXBwb3NlZCB0byBiZSByZXBsYWNlbWVudCB0aGUgQXR0YWNoZW1l
bnQgYmluYXJ5Li4uIGZvciB0ZXN0aW5n
------=_NextPart_POSTCARD_MESSAGE_TAG_5_63
Here is the Mail that I receive:
From: Apache <apache@stargate.solsys.org>
Message-Id: <200203040900.g2490we14000@stargate.solsys.org>
To: mertinj@europe.psi.com
Subject: Postcard from smurphy - A view from la Lenk
Reply-To: smurphy@solsys.org
X-Mailer: PHP/4.0.4pl1Content-Type: multipart/mixed;
boundary="------=_NextPart_POSTCARD_MESSAGE_TAG_5_63"
From: smurphy@solsys.org
Date: Mon, 04 Mar 2002 10:00:58
Message-ID: <Stargate04032002100058smurphy@solsys.org>
MIME-Version: 1.0
This is a multi-part message in MIME format.
------=_NextPart_POSTCARD_MESSAGE_TAG_5_63
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
A view from the Top of the Ski-Region near la Lenk.
--
This message was sent to you through the Image gallery at STARGATE
URL: http://web.solsys.org
Please notify errors to smurphy@solsys.org
------=_NextPart_POSTCARD_MESSAGE_TAG_5_63
Content-Type: image/jpeg;
name="imgp0313.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="imgp0313.jpg"
VGhpcyBpcyBzdXBwb3NlZCB0byBiZSByZXBsYWNlbWVudCB0aGUgQXR0YWNoZW1l
bnQgYmluYXJ5Li4uIGZvciB0ZXN0aW5n
------=_NextPart_POSTCARD_MESSAGE_TAG_5_63
And here is the Code to generate this:
// Preparation for the Mail.
$A_Tag="------=NextPart_POSTCARD_MESSAGE_TAG" . $pic[gal_id] . "_" . $pic[pic_id];
$Signature="\n\n--\nThis message was sent to you through the Image gallery at $titlebar\nURL\
: $nuke_url\nPlease notify errors to $adminmail\n";
$size = filesize($post[post_file]);
$type = filetype($post[post_file]);
// get the content of the file in a string
$PtrAttachedFile = @fopen($post[post_file],"r");
$TmpAttachement = @fread($PtrAttachedFile, $size);
@fclose($PtrAttachedFile);
$TmpAttachement="This is supposed to be replacement the Attachement binary... for testing";
$b64_attachement=base64_encode($TmpAttachement);
$Attachement = chunk_split($b64_attachement, 64 , "\r\n");
// Subject
$Subject = stripslashes($post[post_subject]);
// thats for the Message itself
$Message .= "From: $post[post_from]\n";
$Message .= "Reply-To: $post[post_from]\nX-Mailer: PHP/" . phpversion() . "\n";
$Message .= "Content-Type: multipart/mixed;\n\tboundary=\"" . "$A_Tag\"\n";
$Message .= "Date: " . date("D, d M Y H:i:s") . "\n";
$Message .= "Message-ID: <$sitename" . date("dmYHis") . "$post[post_from]>\n";
$Message .= "MIME-Version: 1.0\n"; // Mime Header
$Message .= "\nThis is a multi-part message in MIME format.\n\n";
$Message .= $A_Tag . "\n";
$Message .= "Content-Type: text/plain;\n";
$Message .= "\tcharset=\"iso-8859-1\"\n";
$Message .= "Content-Transfer-Encoding: 7bit\n\n";
$Message .= stripslashes($post[post_message]);
$Message .= $Signature;
$Message .= "\n" . $A_Tag . "\n";
$Message .= "Content-Type: " . $pic[pic_filetype] . ";\n";
$Message .= "\tname=\"" . $pic[pic_filename] . "\"\n";
$Message .= "Content-Transfer-Encoding: base64\n";
$Message .= "Content-Disposition: attachment;\n";
$Message .= "\tfilename=\"$pic[pic_filename]\"\n\n";
$Message .= $Attachement;
$Message .= "\n" . $A_Tag . "\n";
if (mail("$post[post_to]","$Subject","$Message","$Header")) {
$msg="E-Mail successfully sent to $post[post_to] ...";
} else {
$msg="An unknown error occured while trying to send the Mail. Sorry ...";
}