Jump to content

Attachment .pdf on email is empty


Recommended Posts

Hello, I'm struggling to attach a .pdf file in my email

 

My code is:


original code:
$pdf = new PDF($invoice, PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get('PS_DELIVERY_PREFIX', Context::getContext()->language->id, null, $this->order->id_shop).sprintf('%06d', $this->order->delivery_number).'.pdf';
$file_attachement['mime'] = 'application/pdf';


my code:
$file_attachement['content'] = file_get_contents('http://www.mysite.com.br/boletos/boleto1.pdf');
$file_attachement['name'] = 'Boleto.pdf';
$file_attachement['mime'] = 'application/pdf';
...


 

 

The file is attached and is sending, but is empty

 

I think I'm missing the part of the ['content'], but I have no idea what to do

 

 

Link to comment
Share on other sites

Have you confirmed that render and file_get_contents return the same thing?

 

original code

$file_attachement['content'] = $pdf->render(false);

your code

$file_attachement['content'] = file_get_contents('http://www.mysite.com.br/boletos/boleto1.pdf');

my understanding is that file_get_contents reads the content of the file into a string.  A PDF usually has binary characters, so I'm not sure what you are expecting to occur here?

 

I would suggest researching the PDF render function to better understand what it is returning, I suspect it is not a String

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...