PHP Send email code online

Source: Internet
Author: User
Tags php script php send email

<body>
<form action= "mail.php" method= "POST" >
<b>Email</b><br>
<input type= "text" name= "email" size=40>
<p><b>Subject</b><br>
<input type= "text" name= "subject" size=40>
<p><b>Message</b><br>
<textarea cols=40 rows=10 name= "message" ></textarea>
<p><input type= "Submit" value= "Send" >
</form>
</body>

The form contains the necessary text fields email, subject, message and send button. The production line <form action= "mail.php" method= "POST" > tells the browser the PHP file will handle the form and use what method to send the Data.when user to fill out the form and click the Send button, mail.php file is called ...

<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP _post_vars. *
$email = $HTTP _post_vars[' email '];
$subject = $HTTP _post_vars[' subject '];
$message = $HTTP _post_vars[' message '];
/*validation of subject and also mail */
if (!preg_match ("/w+ [-+.] w+) *@w+ ([-.] w+) *.w+ ([-.] w+) * * * ", $email)) {
echo "echo "<a href= ' JavaScript Tutorial: History.back (1); ' >Back</a> ";
} elseif ($subject = = "") {
echo "echo "<a href= ' javascript:history.back (1); ' >Back</a> ";
}
* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string
otherwise. */
ElseIf (Mail ($email, $subject, $message)) {
echo "} else {
echo "}
?>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.