This option will reset the home page of this site. Restoring any closed widgets or categories.

Reset

Simple PHP mail Script

Simple PHP mail scriptThe script will simply send a mail to the e-mail id you provide in the coresponding field i have given, just check this out..

  1. <html>
  2. <head><title>Mail sender</title></head>
  3. <body>
  4. <form action=”mail.php” method=”POST”>
  5. <b>Email</b><br>
  6. <input type=”text” name=”email” size=40>
  7. <p><b>Subject</b><br>
  8. <input type=”text” name=”subject” size=40>
  9. <p><b>Message</b><br>
  10. <textarea cols=40 rows=10 name=”message”></textarea>
  11. <p><input type=”submit” value=” Send “>
  12. </form>
  13. </body>
  14. </html>

The form contains the necessary text fields Email, Subject, Message, and the Send button. The line<form action=”mail.php” method=”POST”>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…

  1. <html>
  2. <head><title>PHP Mail Sender</title></head>
  3. <body>
  4. <?php
  5. /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
  6. $email = $HTTP_POST_VARS['email'];
  7. $subject = $HTTP_POST_VARS['subject'];
  8. $message = $HTTP_POST_VARS['message'];
  9. /*Validation of subject and also mail */
  10. if (!preg_match(“/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/”, $email)) {
  11.   echo “<h4>Invalid email address</h4>”;
  12.   echo “<a href=’javascript:history.back(1);’>Back</a>”;
  13. } elseif ($subject == “”) {
  14.   echo “<h4>No subject</h4>”;
  15.   echo “<a href=’javascript:history.back(1);’>Back</a>”;
  16. }
  17. /* Sends the mail and outputs the “Thank you” string if the mail is successfully sent, or the error string 
  18. otherwise. */
  19. elseif (mail($email,$subject,$message)) {
  20.   echo “<h4>Thank you for sending email</h4>”;
  21. } else {
  22.   echo “<h4>Can’t send email to $email</h4>”;
  23. }
  24. ?>
  25. </body>
  26. </html>
VN:F [1.5.7_846]
Rating: 7.0/10 (3 votes cast)
VN:F [1.5.7_846]
Rating: +1 (from 1 vote)

Related posts:

  1. HTML E-mail Using PHP
  2. Send Email to Multiple Persons using php
  3. PHP E-mail with attachment
  4. Pass PHP Value To Javascript
  5. Simple Add to favorites script
  6. Simple file upload script using php
  7. Simple PHP Login Script

2 Comments

  1. wandam says:

    good script..

    VA:F [1.5.7_846]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.5.7_846]
    Rating: 0 (from 0 votes)
  2. SUMON says:

    I LIKE IT..

    VA:F [1.5.7_846]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.5.7_846]
    Rating: 0 (from 0 votes)

Leave a Reply

Comments (required)

Spam Protected