MIME attached file contents empty
I am creating and sending a vcard as an email attachment using MIME. The .vcf file creates OK on the server, however when the email is delivered, the attached .vcf file contains no data, as read by outlook and outlook express (data exists in server file). I'm hoping the error is with my encoding.....Anyone with any ideas?
the code i am using is:
$to = "xxx@xxx.xxx";
$subject = "email subject";
$random_hash = md5(date('r', time()));
$headers = "From: [email]yyy@yyy.yyy[/email]";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = chunk_split(base64_encode(file_get_contents("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
Text
--PHP-alt-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
Text
Text
--PHP-alt-$random_hash--
--PHP-mixed-$random_hash
Content-Type: text/vcard; charset=utf-8; name=NewContact.vcf
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random_hash--";
echo @mail($to, $subject, $output, $headers);
Thorby68
Junior Poster in Training
80 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
Did you do a var_dump() or simple echo of $output to see if the file data is actually there?
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101