Jump to content

PHP mail funtion and print email button


raymond_feliciano

Recommended Posts

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.