I'm sending attachment by following mpdf documentation mpdf E-mail a PDF file, and i'm using mailgun API to send mails.
My Code is
$header = "From: ".'donotreply@'.$domain." \r\n";
$header = "Subject: ".'My Subject'." \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$solution->user->id."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$solution->user->id."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $body."\r\n\r\n";
$header .= "--".$solution->user->id."\r\n";
$header .= "Content-Type: application/pdf; name=\"MySetSolution-".$solution->user->id.".pdf\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"MySetSolution-".$solution->user->id.".pdf\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$solution->user->id."--";
$mailgun->sendMessage($domain, array(
'from' => 'donotreply@'.$domain,
'to' => $email_address,
'subject' => 'My Subject',
'text' => $body
),
$header
);
I hv tried both code
$header .= 'Bcc: $emailList';
and
'bcc' => $email_address
but unable to send mail for bcc recipients.
Thanks for any idea if possible.
According to the documentation you should be able to add attachments in an extra array:
I don't think you can add them directly to the header, since the header is added before the body. It will probably result in an incorrect email.