this code is samples of edited AquaticPrime.PHP and Config.PHP. for those not familiar with Aquatic Prime, the AquaticPrime.php requires Config.php.
essentially i'm trying to create a multipart/alternative email with
the multipart/mixed attachment... it works fine except Apple's Mail
app doesn't recognize the multipart/alternative portion of the script
and only displays the HTML version (without giving me the option of
viewing the next alternative). oddly, if i list the Content-Type:
text/plain after Content-Type: text/html, it will only show a text
email in Mail, again without seeing the next alternative. of course
if i view the raw source of the email, everything shows up as it
should.
i know Apple's Mail program is kinda sketchy in Leopard, and i know
i'm not a wizard at PHP, but according to other online samples i've
viewed this should work. anyone see anything in this code that will
make Mail only able to understand the HTML portion of the
email, or maybe it's all as it should be and that Mail is the problem.
thoughts?
essentially i'm trying to create a multipart/alternative email with
the multipart/mixed attachment... it works fine except Apple's Mail
app doesn't recognize the multipart/alternative portion of the script
and only displays the HTML version (without giving me the option of
viewing the next alternative). oddly, if i list the Content-Type:
text/plain after Content-Type: text/html, it will only show a text
email in Mail, again without seeing the next alternative. of course
if i view the raw source of the email, everything shows up as it
should.
i know Apple's Mail program is kinda sketchy in Leopard, and i know
i'm not a wizard at PHP, but according to other online samples i've
viewed this should work. anyone see anything in this code that will
make Mail only able to understand the HTML portion of the
email, or maybe it's all as it should be and that Mail is the problem.
thoughts?
Code:
// PORTION OF AquaticPrime.php
function sendMail($to, $from, $subject, $message, $license, $name, $bcc='')
{
// Create a random boundary
$boundary = "PHP-MIX--".md5(date('r', time()));
$headers = "From: $from\n";
if ($bcc != "")
$headers .= "Bcc: $bcc\n";
$headers .= "X-Mailer: PHP/".phpversion()."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
$headers .= "This is a MIME encoded message.\n";
$headers .= "--$boundary\n";
$headers .= "$message";
$headers .= "--$boundary\n";
$headers .= "Content-Type: application/octet-stream; name=\"$name\"\n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment\n\n";
$headers .= chunk_split(base64_encode($license))."\n";
$headers .= "--$boundary--";
mail($to, $subject, "", utf8_encode($headers));
}
// PORTION OF Config.php
$product = "The Product";
// These fields below should be customized for your application. You can use ##NAME## in place of the customer's name and ##EMAIL## in place of his/her email
$from = "Me <me@domain.com>";
$subject = "$product License For ##NAME##";
$mime_boundary = "PHP-ALT--".md5(time());
$message = "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
$message .= "--$mime_boundary\n";
$message .= "Content-Type: text/plain; charset=\"UTF-8\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= "Plain Text Message\n\n";
$message .= "--$mime_boundary\n";
$message .= "Content-Type: text/html; charset=\"UTF-8\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= "<html>\n";
$message .= "<body>\n";
$message .= "<h2>HTML Message</h2>\n";
$message .= "</body>\n";
$message .= "</html>\n\n";
$message .= "--$mime_boundary--\n\n";