This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Attach pdf file to wp_mail

duc88b wrote on 2016-03-28:
Hi, i'm using PDFCROWD, it's really helpful for me but i have a little issue when sending email with attachment in WordPress.I'm using wp_mail and here is my code:

$html = 'html string..';
$pdf = $client->convertHtml($html);
wp_mail( $email, $title, $mess, '', array( $pdf ) );

And I have received an email without any attachment. Can you help me to fix this?
Thanks in advance
support wrote on 2016-03-29:

I'm not familiar with Wordpress but it seems that the attachment must be specified as a file path. You need to save PDF to a file before sending it as an attachment. Try something like this:
$filename = "/tmp/document.pdf";
$fd = fopen($filename, "wb");
$client->convertHtml($html, $fd);
wp_mail($email, $title, $mess, '', array($filename));
duc88b wrote on 2016-03-30:
i have already done it, thanks for your support