Hey I am having an issue with emailing vcards.
I have attached the vcard to the message using mime.
When using a googlemail client, the VCard is received as an attachment fine,
However if I send this to an iphone it is displayed as raw text under the message.
This is where the strange thing happens if I forward the email from the googlemail client to the iphone, then the vcard appears as an attachment on the Iphone. Can someone tell me if my attachment headers are wrong. My thought is that googlemail may be auto correcting the headers.
The code is below:
$fileatt_type = "text/x-vcard"; // File Type
$fileatt_name = "VCARD.vcf"; // Filename that will be used for the file as the attachment
$email_from = "team@email.co.uk"; // Who the email is from
$email_subject = $firstName." ".$lastName." Vcard"; // The Subject of the email
$email_message = "The Vcard that you requested is attached below!"; // Message that the email has in it
$email_to = $email; // Who the email is too
$headers = "From: ".$email_from;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";
$data = chunk_split(base64_encode($card));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
//Show success view
} else {
//Show error view
die();
}
The vcard itself is auto generated and looks like this:
BEGIN:VCARD
VERSION:2.1
N:Andy;Robinson;
FN:Andy Robinson
TITLE:Mr
ADR;WORK:address
TEL;WORK;VOICE:phone
TEL;WORK;FAX:fax
TEL;CELL;VOICE:mobile
URL;WORK:web
REV:2010-07-27T11:36:54Z
END:VCARD
Any help would be great!