I am pretty new to MIME and PHP, well extremely new, but learning fast. I am currently using this function I wrote to send HTML based emails for me, based on the standard PHP mail function.
function SendCallMail($to,$Subject,$Html)
{
$to =$to;
$subject = $Subject;
$random_hash = md5(date('r', time()));
$headers = "From: s@d.co.za";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<?php echo $Html; ?>
--PHP-alt-<?php echo $random_hash; ?>--
<?
$message = ob_get_clean();
$mail_sent = @mail( $to, $subject, $message, $headers );
//$SendSuccess = $msg->Send();
// echo "EMAIL: ", ($Recipiant);
//echo "Multipart/alternative email was ", ($SendSuccess ? "sent" : "not sent"), "<br>";
$updatequery="UPDATE call_log SET mailed='Y' WHERE callnum='".$val."'";
mysql_query($updatequery);
}
Now thats great, working and all. Now comes the toil of my day, I now need to embed the images into my HTML through MIME using this:
-Content-type: multipart/related;
boundary="multipart_related_boundary"
This is a multi-part message in MIME format.
--multipart_related_boundary
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<p></p>
--multipart_related_boundary
Content-Type: image/jpeg; name="ds.jpg"
Content-Transfer-Encoding: base64
Content-ID: <ds>
Content-Disposition: inline; filename="ds.jpg"
/9j/4AAQSkZJRgABAQEAYABgAAD/4QAWRXhpZgAASUkqAAgAAAAAAAAAAAD.....
How on earth do I combine these two to work together? Please can someone put this together for me. I have been trying to get this to work ALL day, when it works im gnna fart sunshine and whistle butterflies! The other thing is I do not under any circumstance want to use another email wrapper type thing to do this.