raymond_feliciano Posted February 29, 2012 Share Posted February 29, 2012 I apologize if I am in the wrong forum so I hope somebody can help. I have a function which sends an emails to client everytime an order is processed. They have asked me to add a print button in the emails so they could just print the email. I have tried using javascript and call the window.print function but when I click the button nothing happens. I know that it is possible to add a print button in an email but I can't figure out what I am doing wrong. Here is some of the code use to create the email using paypal ipn script. $body = "<html>". "<head>". "<script type='text/javascript'>". "//<![CDATA[ function PrintEmail(){ window.print(); } //]]> ". "</script>". "</head>". "<body>". "<a href='javascript:window.print()'>Print Page</a><br />". "<input type='button' onclick='javascript:PrintEmail();' value='Print This Page' /><br /><b>Customer Name</b>: ".$name."<br />"; foreach($id_str_array as $key => $value){ $id_quantity_pair = explode(":", $value); $product_id = $id_quantity_pair[0]; // Get the product ID $cameo_color = $id_quantity_pair[1]; $product_quantity = $id_quantity_pair[2]; // Get the quantity $product_line1 = $id_quantity_pair[3]; // Get Line 1 $product_line2 = $id_quantity_pair[4]; // Get Line 2 $product_picture = $id_quantity_pair[5]; // Get picture $discount_code = $id_quantity_pair[6]; $body .= "<b>Product</b>: ".$product_id."<br />". "<b>Quantity</b>: ".$product_quantity."<br />". "<b>Engraving Line 1</b>: ".$product_line1."<br />". "<b>Engraving Line 2</b>: ".$product_line2."<br />". "<b>Your picture</b>: <img src='http://t3.sysguru.com/mcf/pictures/".$product_picture."' height='300' width='556' /><br />"; } $body .= "<b>Total</b>: $".$_POST['mc_gross']."</body></html>"; $subject = "Transaction Completed"; $mailer->SendPayPalInfo($subject, $body); I tried just calling the javascript print function with a link and aslo create a function and called the function from the button and neither of these methods work. here is the code which send the message out. function SendPayPalInfo($subject, $body){ $headers = "From: " .EMAIL_FROM_ADDR. "\r\n"; $headers .= "Reply-To: ".EMAIL_FROM_ADDR."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; return mail(EMAIL_FROM_ADDR, $subject, $body, $headers); } Am I missing something in the headers of am I coding this wrong? Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/258003-php-mail-funtion-and-print-email-button/ Share on other sites More sharing options...
ManiacDan Posted February 29, 2012 Share Posted February 29, 2012 Are they not capable of printing the email using their email client? ctrl+p will print in every email client and web browser I've ever used. Quote Link to comment https://forums.phpfreaks.com/topic/258003-php-mail-funtion-and-print-email-button/#findComment-1322471 Share on other sites More sharing options...
raymond_feliciano Posted February 29, 2012 Author Share Posted February 29, 2012 They are but they want me to add this button and I have been working on it all day with no luck. Quote Link to comment https://forums.phpfreaks.com/topic/258003-php-mail-funtion-and-print-email-button/#findComment-1322474 Share on other sites More sharing options...
requinix Posted February 29, 2012 Share Posted February 29, 2012 Spend a minute trying to convince them that it's a stupid idea. Because it is. I, for one, would not at all be surprised if said print button didn't always work in all clients. Imagine how frustrated users would be if they clicked this button and it did absolutely nothing... Quote Link to comment https://forums.phpfreaks.com/topic/258003-php-mail-funtion-and-print-email-button/#findComment-1322490 Share on other sites More sharing options...
ManiacDan Posted February 29, 2012 Share Posted February 29, 2012 I bet their client strips javascript, that's why I said that. They already have a print button, it's right there at the top of their screen. Forcing you to add another one is stupid. Tell them "emails can be printed using the method best appropriate for your email client. As some email clients block such functionality, and some have completely separate printing formats, adding this button would decrease functionality." Quote Link to comment https://forums.phpfreaks.com/topic/258003-php-mail-funtion-and-print-email-button/#findComment-1322530 Share on other sites More sharing options...
raymond_feliciano Posted March 1, 2012 Author Share Posted March 1, 2012 Thanks guys I told them and they scratched that idea. My boss and I both agree with you and we told them ot would be a stupid idea. Its a good thing because from the look of things I think the javascript was is being stripped away so it would've defeated the purpose. Quote Link to comment https://forums.phpfreaks.com/topic/258003-php-mail-funtion-and-print-email-button/#findComment-1322736 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.