tags:

views:

171

answers:

4

I have a function that automatically exports a table into a CSV file, then I try to attach that same file into a function that will email it. I have sent attachments using html mime mail before, but I was wondering if that created CSV file needs to be stored on the server first before attaching it to the email?

+2  A: 

It depends on your functions, if you have a function that can export the table as CSV into a string and then the mail functions support creating attachments from a string then I think you have what you need...

Chris Kimpton
I just read up on html mime mail and it did mention it can attach files from php strings.
Brad
A: 

In theory you could embed it yourself by writing the appropriate tags and handcrafing the email yourself.

Or you can go the easy way and save it to a temporary location, use a tool like PHPMailer (which might also support string attachment) to attach the file, send the mail and then remove the temp file.

ptor
A: 

When you attach a binary to an email it converts the binary to text so it can be transmitted via a text medium. A conversion process call uuencode is used to convert the binary.

So when you attach a file using a client, it just uuencodes it and adds the text in with the rest of the message. I am not sure on the exact format to get it to look like an attachment for the client though (rather than just gibberish in the body of the message).

vfilby
A: 

If you use the Mail_Mime package from PEAR and its "addAttachment" method, set the "$isfile" (4th) argument to false and pass the string as the "$file" (1st) argument. More here.

If you use PHPMailer, use its "AddStringAttachment" method.

If you don't use those then you need to be more specific.

Milen A. Radev