I have a script that sends a multipart/mixed e-mail, it sends HTML and an attached vCard. If I check the e-mail on my iPhone or my mail client, it works fine. But when I test it on a co-worker's Android phone, the message has no content, but it says there are 2 attachments. If I click on the first attachment, it opens an HTML viewer and I can see the HTML part of the message, or I can click on the vCard and it will add it. Since the instructions to add a vCard are in the HTML, I need that to render when the message is opened, like it does on my iPhone.
Here's my code:
<?php
$email_to = "brian@domain.com";
$email_from = "brian@domain.com";
$email_subject = "TA vCard";
$vcard_type = "individual";
$v_type = "company";
$v_company = "TA Experts";
$v_email = "experts@ta.com";
$v_web = "www.ta.com/experts";
$v_phone = "866-555-5555";
$vt = "WORK";
$vcard_content = "BEGIN:VCARD\r";
$vcard_content .= "VERSION:3.0\r";
$vcard_content .= "FN:".$v_company."\r";
$vcard_content .= "ORG:".$v_company.";\r";
$vcard_content .= "EMAIL;type=INTERNET;type=".$vt.";type=pref:".$v_email."\r";
$vcard_content .= "TEL;type=".$vt.";type=pref:".$v_phone."\r";
$vcard_content .= "item2.URL;type=pref:".$v_web."\r";
$vcard_content .= "X-ABShowAs:COMPANY\r";
$vcard_content .= "END:VCARD";
$message = '<html><head><title>TA - vCard</title></head><body><p>Thank you for downloading our vCard, please click on the link to add the contact information to your device.</p></body></html>';
$data = $vcard_content;
$data = chunk_split(base64_encode($data));
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "From: ".$email_from;
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;" . " boundary=\"{$mime_boundary}\"";
$message .= "This is a multi-part message in MIME format.\n\n";
$message .= "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n" . "Content-Type: application/octet-stream;\n" . " name=\"TAExperts.vcf\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
$email_status = mail($email_to, $email_subject, $message, $headers);
echo $email_status ? "Success" : "Fail";
?>
Any help would be greatly appreciated!
Brian