Wednesday 20 August 2014

Button click to send email in php

<form action="" method="post">
    <input type="submit" value="Send details to...." />
    <input type="hidden" name="button_pressed" value="Email" />
</form>

<?php

if(isset($_POST['button_pressed']))
{
    $to      = 'who@example.com';
    $subject = 'subject Message';
    $message = 'All is well';
    $headers = 'From: fhfh@example.com' . "\r\n" .
        'Reply-To: fhfh@example.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
$headers .= 'Cc: myham@example.com' . "\r\n"; 
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 

    mail($to, $subject, $message, $headers);

    echo 'Email Sent.';
}

?>

No comments:

Post a Comment