Add Attachments from DB

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
abax
Forum Newbie
Posts: 1
Joined: Thu Apr 03, 2008 2:42 am
Location: Italy, Ravenna

Add Attachments from DB

Post by abax »

Hello! :D

I have a problem... I need to attach some files directly from a DB (stored with a base64 codify etc..) , if possible without creating the file on my file system.

There is a function that allow this operation?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Add Attachments from DB

Post by Chris Corbyn »

Yes, just do it the same as usual but replace "new Swift_File()" with the raw data.

For example, if I wanted to "attach" a text file (using text as the example because it's obvious to give an example for) then I can do:

Code: Select all

$message->attach(new Swift_Message_Attachment('Contents of my imaginary text file', 'filename.txt', 'text/plain'));
Post Reply