mythri Posted June 22, 2017 Share Posted June 22, 2017 Hi All,I am able to generate pdf and send that generated pdf as attachment to entered email-id. But i want something like, when i click on email it should generate pdf and open a form with user entry fields like To, Message, Subject.... etc... And that generated pdf should show as attachmentNow when click on email it will open an user entry form then when i click on send , it will generate pdf and send that pdf.Here is my codeMy html form <form method="post" action="send_mail.php" enctype="multipart/form-data"> <div class="formSep"> <label class="req">To Email: </label> <input type="text" name="email" /> <select name="email"><option value="">Select one</option><?php $s1 = mysql_query("select * from lead_contact where company_id=".$company.""); while($r1 = mysql_fetch_array($s1)) { $name = $r1['firstname'].' '.$r1['lastname']; $cid = $r1['con_id']; $cemail = $r1['email']; ?> <option value="<?php echo $cemail;?>"><?php echo $name;?></option> <?php } ?> </select> </div> <input type="hidden" name="order_id" value="<?php echo $order_id; ?>" /> <input type="hidden" name="company" value="<?php echo $company; ?>" /> <div class="formSep"> <label class="req">Subject</label> <input type="text" name="subject" /></div> <div class="formSep"> <label class="req"> Message</label> <div class="w-box" id="n_wysiwg"> <div class="w-box-header"> <h4>WYSIWG Editor</h4> </div> <div class="w-box-content cnt_no_pad"> <textarea name="message" id="wysiwg_editor" cols="30" rows="10"></textarea> </div> </div> </div> <div class="formSep"> <input type="submit" name="submit" value="Submit" class="btn btn-info" /></div> </form> send_email.php <?php if($_POST['submit'] == "Submit") { $id = $_POST['order_id']; $company = $_POST['company']; include("../admin_auth.php"); include("../connect.php"); require('invoice.php'); $pdf = new PDF_Invoice( 'P', 'mm', 'A4' ); $pdf->AddPage(); //MY PDF CODE GOES HERE $pdf->Output("D:/wamp/www/folder/uploads/".$id.".pdf","F"); $path = "D:/wamp/www/folder/uploads/".$id.".pdf"; require("class.phpmailer.php"); require("class.smtp.php"); $to = $_POST['email']; $from = $_SESSION['email']; $message = $_POST['message']; $subject = $_POST['subject']; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Mailer = "smtp"; $mail->Host = "hostname"; $mail->SMTPAuth = true; $mail->Username = 'user'; $mail->Password = 'password'; $mail->Port = 587; $mail->From=$_SESSION['email']; $mail->FromName=$_SESSION['name']; $mail->Sender=$email; $mail->AddAddress($to); $mail->AddBCC("test@test.com"); $mail->AddAttachment($path, '', $encoding = 'base64', $type = 'application/pdf'); $mail->Subject = $subject; $mail->CharSet="windows-1251"; $mail->CharSet="utf-8"; $mail->IsHTML(true); $mail->Body = $message; if(!$mail->Send()) { echo "Error sending: " . $mail->ErrorInfo;; } else { echo "Email Sent!"; } } ?> I am not getting how to get the form with pdf attached, so that user can write in the body , add cc and sent email Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 22, 2017 Share Posted June 22, 2017 From your somewhat readable post, it sounds like you are getting what you want but then you say you aren't. What exactly does "click on email" mean? Are you clicking on an email message somewhere? Sounds like you want to present the user with a form to collect the data you want and then have the action direct you to a script that grabs those inputs and also generates the pdf and then does the email send for you. So - what's the problem? Quote Link to comment Share on other sites More sharing options...
mythri Posted June 23, 2017 Author Share Posted June 23, 2017 Thanks for reply! Actually i am getting the form, but pdf is not getting attached in the form. Thats the problem Quote Link to comment Share on other sites More sharing options...
mythri Posted June 23, 2017 Author Share Posted June 23, 2017 (edited) I want like this. is there any script or anything i should integrate with my script? Please suggest Edited June 23, 2017 by mythri Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 23, 2017 Share Posted June 23, 2017 What do you mean by "but pdf is not getting attached in the form"? "attached IN the form"? Whatever is that? From your (again - sketchy) description it sounds like the pdf is something you create, not something that you get "from a form". Please make yourself a bit clearer. Quote Link to comment Share on other sites More sharing options...
mythri Posted June 23, 2017 Author Share Posted June 23, 2017 Sorry for my communication. I will be displaying data like this When i click on email symbol, it should generate a pdf and display a user entry form with generated pdf as attachment. The form should be like Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 23, 2017 Share Posted June 23, 2017 "email symbol". Oh, that. Yes - you really need to commuicate better. With that - I'm signing off. Quote Link to comment 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.