Solved

can attach a dynamic pdf file to a mail?

Posted on 2008-10-27
4
544 Views
Last Modified: 2008-11-03
hello Expert
I use this free class for create a pdf file with php
http://www.ros.co.nz/pdf/

I have a question :
I generate a dynamic pdf file and when i create it i send a mail to ppppp@ppp.com,
but
Can i attach this dynamic pdf file to a mail?

Tks
0
Comment
Question by:denny3d
4 Comments
 
LVL 17

Expert Comment

by:psimation
ID: 22812209
yes, use a proper php mailer class:

http://phpmailer.sourceforge.net
0
 

Author Comment

by:denny3d
ID: 22812278
ok, for class php mailer, but how i attach my pdf file?
i dont have a phisical pdf file, bu i have a file php that create a temp pdf file.
0
 
LVL 9

Accepted Solution

by:
absx earned 500 total points
ID: 22812742
Hi denny3d,

The easiest way to accomplish this is to find a way to save the generated PDF to a file (with preferably a random file name), then attach this file to the email for sending and finally delete the file. At least the Cpdf class you mention here does write PDF to file, as described in http://www.ros.co.nz/pdf/faq.php#4 .

Using a temporary file saves you having to merge the PDF generating class and the email sending class together to transfer the PDF stream to an attachment.

Hope this helps.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 22821766
I have done this with fpdf -

First, you generate the PDF file and save it in a temporary directory.
Next, you generate the email message, adding the PDF file as an attachment
You send the message, checking the return code from mail()
Then you unlink the PDF.

Man pages here are helpful:
http://www.zend.com/zend/spotlight/sendmimeemailpart1.php
http://pear.php.net/package/Mail_Mime

HTH, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
change password links 7 72
PHP Healthcheck 2 81
Problem with Simple PHP/mySQL Query 3 51
highcharts wont fix inside a bootstrap modal window 6 26
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now