Hi all,
I am trying to e-mail using php and send an attachment with this e-mail but the attachment is not sending and the text on the e-mail isn't correct here is the e-mail i'm receiving--
------=MIME_BOUNDRY_message_parts
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
blah blah -- plaintext version of the message
------=MIME_BOUNDRY_message_parts
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><BODY> blah blah -- html version of the message <IMG src=3D"cid:some_picture"> </BODY></HTML>
------=MIME_BOUNDRY_message_parts--
------=MIME_BOUNDRY_main_message
Content-Type: image/gif;
name="some_picture.gif"
Content-Transfer-Encoding: base64
Content-ID: <some_picture>
R0lGODlheAAZAKIHAMTExCQkJJOTk
eLo7wzDKSatVQ5R3u7dDUUjcZ34D
------=MIME_BOUNDRY_main_message--
and here is my code
<?php
// some local variables
$from_name = "Niall";
$from_email = "niall_buckley@eircom.net";
$to_name = "Niall";
$to_email = "niall.buckley@bsci.com";
$subject = "Fantastic Subject";
// headers need to be in the correct order...
$headers = "From: $from_name<$from_email>\n";
$headers .= "Reply-To: <$from_email>\n";
$headers .= "MIME-Version: 1.0\n";
// the following must be one line (post width too small)
$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"---- MIME_BOUNDRY_main_message\"\n";
//
$headers .= "X-Sender: $from_name<$from_email>\n";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <$from_email>\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
//plaintext section begins
$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your text goes here
$message .= "blah blah -- plaintext version of the message\n";
$message .= "\n";
// html section begins
$message .= "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/html;\n charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your html goes here -- It didn't appear properly without
// the weird markup that outlook added after sending
$message .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
$message .= "<HTML><BODY>\n";
$message .= "blah blah -- html version of the message\n";
// look ma, I'm referencing an img attachment (see below)
// watch out for weird markup!!!
$message .= "<IMG src=3D\"cid:some_picture\">\n";
$message .= "</BODY></HTML>\n";
$message .= "\n";
// this ends the message part
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
// now we add attachments (images, etc)
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "Content-Type: image/gif; \n name=\"some_picture.gif\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-ID: <some_picture>\n";
$message .= "\n";
// (truncated for space)
$message .= "R0lGODlheAAZAKIHAMTExCQkJJOTk\n";
$message .= "eLo7wzDKSatVQ5R3u7dDUUjcZ34D\n";
$message .= "\n";
// etc...etc...etc...
//message ends
$message .= "------=MIME_BOUNDRY_main_message--\n";
// send the message :-)
mail("$to_email", $subject, $message, $headers);
?>
can someone please help....any suggestions at all would help
Rgds
Niall