vivekanandch Posted August 21, 2011 Share Posted August 21, 2011 I'm a beginner in PHP I was wondering if this is easy to do or if i'd have to outsource this to a programmer - Basically when a user fills in the PHP Form and submits it I need this to generate as a PDF which will then email/attach to MY email and NOT the user who submitted this form. I have looked at tcpdf, fpdi but i dont think any of those scripts allow me to do this specifically as from what i heard it generates a download link for the user, and that is not what i need. If anyone can help me it would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/ Share on other sites More sharing options...
voip03 Posted August 21, 2011 Share Posted August 21, 2011 Can you use FPDF? Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/#findComment-1260255 Share on other sites More sharing options...
jcbones Posted August 21, 2011 Share Posted August 21, 2011 Have you tried FPDF, I know you can send it to the browser, save it as a file (to email), force download it, or save it to a variable as a string. Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/#findComment-1260259 Share on other sites More sharing options...
vivekanandch Posted August 21, 2011 Author Share Posted August 21, 2011 oh thanks i used fpdf, now i can create pdf files, but the real thing is i want to send it as an email attachment...can any one guide me.. Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/#findComment-1260281 Share on other sites More sharing options...
voip03 Posted August 21, 2011 Share Posted August 21, 2011 <?php //define the receiver of the email $to = 'recivermail@name.com'; //define the subject of the email $subject = 'Test email with attachment'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com"; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents('somefile.pdf'))); //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-mixed-<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello World!!! This is simple text email message. --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <h2>Hello World!</h2> <p>This is something with <b>HTML</b> formatting.</p> --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php echo $random_hash; ?> Content-Type: application/zip; name="attachment.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; ?> --PHP-mixed-<?php echo $random_hash; ?>-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/#findComment-1260291 Share on other sites More sharing options...
voip03 Posted August 22, 2011 Share Posted August 22, 2011 Can you market SOLVED. Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/#findComment-1260413 Share on other sites More sharing options...
vivekanandch Posted August 22, 2011 Author Share Posted August 22, 2011 no firstly i need to create html file say invoice to pdf and i have to send that pdf as an email attachment.. first off all im not getting how to do html to pdf itself...VOIP do u know? Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/#findComment-1260414 Share on other sites More sharing options...
voip03 Posted August 22, 2011 Share Posted August 22, 2011 http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php Quote Link to comment https://forums.phpfreaks.com/topic/245367-how-to-make-pdf-files-using-php5-on-windows-and-also-send-pdf-as-an-email/#findComment-1260420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.