Can anyone tell me where I've gone wrong on this? I'm adding an attachment to an email from a blob in the database. I'm assuming the headers on this are incorrectly formatted but have spent all day on this and still cant get it to work!
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers2 = array(
'From: ' . $fromName . ' < ' . $fromEmail . ' > ',
'BCC: will.evans.1972@gmail.com',
'MIME-Version: 1.0',
'Content-Type: multipart/mixed;',
'boundary='.$mime_boundary,
);
// multipart boundary
$body = '--'.$mime_boundary.'
' ;
$body .= 'Content-Type: text/html; charset=\"iso-8859-1\"
';
$body .= $message ;
$body .= '--'.$mime_boundary.'
';
// preparing attachments
global $wpdb;
$data = $wpdb->get_var("SELECT documentblob FROM quote");
$data = chunk_split(base64_encode($data));
$fname1='quotation.pdf';
$body .= 'Content-Type: {"application/octet-stream"};
';
$body .= 'name="'.$fname1.'"
'.
$body .= 'Content-Disposition: attachment;
';
$body .= 'filename="'.$fname1.'"
';
$body .= 'Content-Transfer-Encoding: base64
';
$body .= $data . '
';
$body .= '--'.$mime_boundary.'
';
wp_mail($to, $subject, $body, $headers2);