Skip to content

Instantly share code, notes, and snippets.

@iamjonbradley
Created May 18, 2011 14:54
Show Gist options
  • Save iamjonbradley/978735 to your computer and use it in GitHub Desktop.
Save iamjonbradley/978735 to your computer and use it in GitHub Desktop.
Attach VCARD with Zend_MAIL
<?php
include ('Zend/Mime.php');
include ('Zend/Mail/Transport/Abstract.php');
include ('Zend/Mail.php');
$mail = new Zend_Mail();
// create the vcard
$vcardText="BEGIN:VCARD\n VERSION:2.1\nFN:[name]\TEL;HOME;VOICE:[phone]\nEMAIL;PREF;INTERNET:[email]\nEND:VCARD";
$vcardText = str_replace("[name]", $member['name'], $vcardText);
$vcardText = str_replace("[email]", $member['email'], $vcardText);
$vcardText = str_replace("[phone]", $member['phone'], $vcardText);
$at = $mail->createAttachment($vcardText);
$at->type = 'text/x-vcard';
$at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$at->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
$at->filename = 'contact.vcf';
// set the email
$mail->addTo($row['sellerEmail'], $row['sellerName']);
$mail->setFrom($member['email'], $member['name']);
$mail->setSubject($subject);
$mail->setBodyText($message);
$mail->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment