Advertisement
aivavic

attach

Dec 20th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. // Create your file contents in the normal way, but don't write them to disk
  2. $data = create_my_pdf_data();
  3.  
  4. // Create the attachment with your data
  5. $attachment = Swift_Attachment::newInstance($data, 'my-file.pdf', 'application/pdf');
  6.  
  7. // Attach it to the message
  8. $message->attach($attachment);
  9.  
  10.  
  11. // You can alternatively use method chaining to build the attachment
  12. $attachment = Swift_Attachment::newInstance()
  13.   ->setFilename('my-file.pdf')
  14.   ->setContentType('application/pdf')
  15.   ->setBody($data)
  16.   ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement