Page 1 of 1

Emailing attachments - with a twist!

Posted: Sun Mar 21, 2004 1:09 pm
by magicrobotmonkey
Here's what I'm doing. I'm using FPDF library to create a pdf file populated with data culled from DB and forms. So far so good. It is displayed for the user to see/save/print. But now I have to also e-mail it to the user. I'm not sure how to go about this. Because it is dynamically created, I can't just fopen it as usual. Obviously, when dusplaying it, I link to a .php file which then tells the browser it has a pdf file coming then sends pdf-looking data. I am just at a loss as how to get that data and send it. Any ideas? (PS, I'm alse new to the mail() function, having only used it so far for simple admin, debugging emails to myself where I didn't care about formatting or anything. But I figure I can learn that alright from the documentation and other posts)

Posted: Mon Mar 22, 2004 6:04 am
by magicrobotmonkey
Seriously? No ideas? Or did I just explain it bad?

Posted: Mon Mar 22, 2004 10:29 am
by magicrobotmonkey
Still nothing, huh?

Posted: Mon Mar 22, 2004 10:58 am
by patrikG
I would save it to a to a temporary file, send off the email avec attachment as usual and then delete the file.

Posted: Mon Mar 22, 2004 11:03 am
by magicrobotmonkey
crap I was hoping that wouldnt be the answer...

Posted: Mon Mar 22, 2004 11:06 am
by patrikG
Alternatively you could just make a cup of tea. But I don't think that would be a solution...;)

Seriously: there may be other ways, but I should think them to be more complicated than simply writing and deleting a file.

Posted: Mon Mar 22, 2004 11:10 am
by magicrobotmonkey
Hey congrats on you 1000th post and I think im going to investigate just how FPDF makes a pdf before deciding on the best course of action. I was just hoping someone would have experienced this before and happen to have an idea about how to do it. Thanks!

Posted: Mon Mar 22, 2004 11:16 am
by patrikG
magicrobotmonkey wrote:Hey congrats on you 1000th post

Thanks :)
magicrobotmonkey wrote:I think im going to investigate just how FPDF makes a pdf before deciding on the best course of action. I was just hoping someone would have experienced this before and happen to have an idea about how to do it. Thanks!
I'd rather investigate the mail function first (this article may be handy) and then FPDF. When you've found a solution without writing to a file, please post it - I'd be very interested. :)

Posted: Mon Mar 22, 2004 11:22 am
by magicrobotmonkey
Ok, just to let you know what I'm thinking is to somehow run the php file that creates the PDF and grab the output of it, inserting that into the email as a binary attachment deal - Not exactly sure how I'm going to do that just yet and I'm currently at work and supposed to be managing accounts not playing with php so I'll mess with it tonight. Oh - and I already read that article, so I feel like I know what I need to be able to put into the mail, its just a matter of getting it!

Posted: Mon Mar 22, 2004 11:24 am
by patrikG
You'd need to MIME-encode it...but that's as far as my knowledge goes...