Simple PHP mail script

Simple PHP mail scriptSimple PHP mail script
Simple php mail 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)…


Mail sender

Email

Subject

Message


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

tells the browser which PHP file will process the form and what method to use for sending data.

When the user fills in the form and hits the Send button, the mail.php file is called…


PHP Mail Sender

Invalid email address";
  echo "Back";
} elseif ($subject == "") {
  echo "

No subject

"; echo "Back"; } /* 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 "

Thank you for sending email

"; } else { echo "

Can't send email to $email

"; } ?>