Hi,

I am working in php a mail function in this function in message part i want to use one print button which should be mailed to and if who is getting mail want to print this page that should be print. But which code i am using for print button in message that is not working well.

So please help me . How i can do this if there is any other code or help ??

here is code which i am using like this:

<?php

$to="mymail@gmail.com";
$subject="Test Mail";
$message="Hi this is test mail."
$message.="<input type=button value=Print onClick=window.print()>";
$from="test@gmail.com";
mail($to,$subject,$message,$from); 
?>

But in this case button Print is not working well.
Please help me to how i can do this in mail message .

Thanks,
Kparas

Recommended Answers

All 3 Replies

in line 6 you forgot ";"

$message="Hi this is test mail."; /*<---- you forgot ; semicolon
$message.="<input type='button' value='Print' onClick='window.print();'>";

try this. i am not tested it.

if sending html you need to change the header of your email.

$from  = 'MIME-Version: 1.0' . "\r\n";
$from .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$from .="test@gmail.com";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.