Hi All,
I'm pulling out what little is left of my hair. I am trying to configure a multipart MIME mail that will attach a vcard I've been able to successfully create.
The code below finds the vcard file on my server, but when it deliveres it it delivers it with on 60b (that's bytes not Kš and of course the vcard is devoid of any data. I have interrogated the saved vard fil on the server and this is A OK. I think there must something wrong with my encoding....Please, please help someone, just a few strands of hair left for my next project
My code, adapted from the guys at geekology
$to = "thorby68@live.co.uk";
$subject = "vcard";
$random_hash = md5(date('r', time()));
$headers = "From: Thorby on the web";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = chunk_split(base64_encode(file_get_contents("../Pages/NewContact.vcf")));
$output = "
--PHP-mixed-$random_hash;
Content-Type: multipart/alternative; boundary='PHP-alt-$random_hash'
--PHP-alt-$random_hash
Content-Type: text/plain; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
Vcard Attached
--PHP-alt-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
<h2>Vcard</h2>
<p>Attached.</p>
--PHP-alt-$random_hash--
--PHP-mixed-$random_hash
Content-Type: text/x-vcard; name=NewContact.vcf
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random_hash--";
echo @mail($to, $subject, $output, $headers);