PHP Classes

String attachments

Recommend this page to a friend!

      MIME E-mail message sending  >  MIME E-mail message sending package blog  >  How Can PHP Send Emai...  >  All threads  >  String attachments  >  (Un) Subscribe thread alerts  
Subject:String attachments
Summary:Attachments without the use of a temporary file
Messages:5
Author:Steve Nagy
Date:2014-11-03 18:12:49
 

  1. String attachments   Reply   Report abuse  
Picture of Steve Nagy Steve Nagy - 2014-11-03 18:12:49
Hi,

First off, this is a great package and we love using it.

We currently send messages with a pdf attachment generated with HTML2PDF. The file is written to a temp directory and then this file is added to the e-mail message. Is it possible to create an attachment part directly from the contents of a PHP variable an, if so, how?

Thanks,
Steve Nagy

  2. Re: String attachments   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-03 22:24:08 - In reply to message 1 from Steve Nagy
Sure, when you call AddFilePart, you can pass the parameters array with an entry named Data that should pass the string of content data of your file.

  3. Re: String attachments   Reply   Report abuse  
Picture of Steve Nagy Steve Nagy - 2014-11-03 22:49:30 - In reply to message 2 from Manuel Lemos
Hi Manuel,

Just to be sure, there would be no file, just a variable containing a pdf image. What would the array look like?

Thanks,
Steve

  4. Re: String attachments   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-04 04:52:55 - In reply to message 3 from Steve Nagy
It could be something like this:

$part = array(
'Data'=>$pdf_data,
'Name'=>'some-document.pdf',
'Content-Type'=>'application/pdf'
);

  5. Re: String attachments   Reply   Report abuse  
Picture of Steve Nagy Steve Nagy - 2014-11-04 14:33:15 - In reply to message 4 from Manuel Lemos
Worked like a charm. Thanks Manuel!