/ Published in: PHP
URL: http://css-tricks.com/snippets/php/send-email/
Expand |
Embed | Plain Text
1) HTML Form with Inputs <form action="" method="post"> <label for="name">Name:</label> <input type="text" name="name" id="name" /> <label for="Email">Email:</label> <input type="text" name="email" id="email" /> <label for="Message">Message:</label><br /> <textarea name="message" rows="20" cols="20" id="message"></textarea> <input type="submit" name="submit" value="Submit" /> </form> 2) Process with PHP This could be in a seperate file (e.g. sendemail.php) in which you'd set the action URL of the form to go there. Or, have the form submit to itself (leave action URL blank) and test for one of the values of the form being POSTed and process there. <?php // from the form // set here $subject = "Contact form submitted!"; $to = 'your@email.com'; $body = <<<HTML $message HTML; $headers = "From: $email "; $headers .= "Content-type: text/html "; // send the email // redirect afterwords, if needed ?> 3) Test it And make sure to keep up with security news around the web.
You need to login to post a comment.
