Simple PHP mail script

This script is not only educational, but also applicable for practical Web development. It allows you to place a simple form for sending emails on any HTML page. The script shows you how to gather user input, perform form validation with PHP, and send an email.

First, make the form page mail.html (you may call it whatever you like)…

<head><title>Mail sender</title></head>
<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><p><b>Message</b><br />
<textarea cols=40 rows=10 name="message"></textarea>
</p><p><input type="submit" value=" Send "/>

The form contains the necessary text fields Email, Subject, Message, and the Send button. The line

Continue reading Simple PHP mail script