Vcard using PHP

Hi The following code may be useful to send a vcard using PHP:

$type=”WORK”;
$vcard_content  = “BEGIN:VCARD\r\n”;
$vcard_content .= “VERSION:3.0\r\n”;
$vcard_content .= “CLASS:PUBLIC\r\n”;
$vcard_content .= “FN:”.$firstname.” “.$lastname.”\r\n”;

$vcard_content .= “TITLE:”.$yourtitle.” “.”\r\n”;
$vcard_content .= “ORG:”.$yourtitle.”\r\n”;
$vcard_content .= “EMAIL;type=INTERNET;type=pref:”.$email.”\r\n”;
$vcard_content .= “TEL;type=”.$type.”;type=pref:”.$telefonnr.”\r\n”;
$vcard_content .= “TEL;type=CELL:”.$mobnr.”\r\n”;
$vcard_content .= “TEL;type=”.$type.”;type=FAX:”.$faxnr.”\r\n”;
$vcard_content .= “item1.ADR;type=”.$type.”;type=pref:;;”.$street.” “.housenr.”;”.$city.”;”.$state.”;”.$zipcode.”\r\n”;
$vcard_content .= “item2.URL;type=pref:”.$url.”\r\n”;
$vcard_content .= “END:VCARD”;

$fileatt_type = “text/x-vcard”;

$data = $vcard_content;
$data = chunk_split(base64_encode($data));

The above code should be sent as message in mail body.Please share your thoughts .

Leave a Reply

Your email address will not be published. Required fields are marked *