php – SMTP Send mail using PHPMailer PHP Contact Form

php – SMTP Send mail using PHPMailer PHP Contact Form

Welcome on live24u.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to php – SMTP Send mail using PHPMailer PHP Contact Form

In this post we will show you Best way to implement How to Create Contact Form with PHPMailer to send mails, hear for How to Email Form – Simple Form to Email PHP Contact Form with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

You can download source code and Demo from below link.




HTML Form

<?php 
if(isset($_GET['respnose']) && $_GET['respnose'] == 'success') {
      echo '<div class="response_success" > Thank we for contacting us. We will get back to we soon. </div> ';
} ?>
<style>
     .response_success {
          background-color: #fed;
          color: green;
          border: 1px solid green; 
     }
</style>
<form name="live24u-contact-form" method="post" action="live24u-contact-process.php">
<table width="450px">
</tr>
<tr>
<td align="center">
<label for="client_name">client_name *</label>
</td>
<td align="center">
<input type="text" name="client_name" maxlength="50" size="30">
</td>
</tr>

<tr>
<td align="center"">
<label for="client_last_name">client_last_name *</label>
</td>
<td align="center">
<input type="text" name="client_last_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td align="center">
<label for="email">Email Address *</label>
</td>
<td align="center">
<input type="text" name="email" maxlength="80" size="30">
</td>

</tr>
<tr>
<td align="center">
<label for="conatct">conatct Number</label>
</td>
<td align="center">
<input type="text" name="conatct" maxlength="30" size="30">
</td>
</tr>
<tr>
<td align="center">
<label for="email_subject">email_subject</label>
</td>
<td align="center">
<input type="text" name="email_subject" maxlength="30" size="30">
</td>
</tr>
<tr>
<td align="center">
<label for="message_data">message_data *</label>
</td>
<td align="center">
<textarea name="message_data" maxlength="1000" cols="25" rows="6"></textarea>
</td>

</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit"> ( <a href="client_last_name">Get Help from live24u tut.</a> )
</td>
</tr>
</table>
</form>

PHP

<?php
require_once("PHPMailerAutoload.php"); // this will include smtp and pop files.

if(isset($_POST['email'])) {

   $email_to = "info@live24u.com";

   function simple_deid($error) {// wer error code can go here
        echo "We're sorry, but there's errors found with the form we submitted.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
   }
   if(!isset($_POST['client_name']) ||!isset($_POST['client_last_name']) ||!isset($_POST['email']) ||!isset($_POST['conatct']) ||!isset($_POST['email_subject']) || !isset($_POST['message_data'])) {
       simple_deid('We are sorry, simple but there appears new to be a problem get data with the form we submitted.'); 
   }

   $client_name = $_POST['client_name']; // data required
   $client_last_name = $_POST['client_last_name']; // data required
   $simple_email_form = $_POST['email']; // data required
   $conatct = $_POST['conatct']; // not data required
   $email_subject = $_POST['email_subject']; // data required
   $message_data = $_POST['message_data']; // data required

   $error_message = "";
   $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
   if(!preg_match($email_exp,$simple_email_form)) {
       $error_message .= 'The Email Address we just enter data does not appear to be check valid.<br />';
   }
   $exp_string = "/^[A-Za-z .'-]+$/";
   if(!preg_match($exp_string,$client_name)) {
      $error_message .= 'The client_name Name we just enter data does not appear to be check valid.<br />';
   }
   if(!preg_match($exp_string,$client_last_name)) {
       $error_message .= 'The client_last_name Name we just enter data does not appear to be check valid.<br />';
   }
   if(!preg_match($exp_string,$email_subject)) {
      $error_message .= 'The email_subject we just enter data does not appear to be check valid.<br />';
   }
   if(strlen($message_data) < 2) {
       $error_message .= 'The message_data we just enter data do not appear to be check valid.<br />';
   }
   if(strlen($error_message) > 0) {
       simple_deid($error_message);
   }
   $email_message = "\n\n";

   $email_message .= "client_name: ".clean_string($client_name)."\n";
   $email_message .= "client_last_name: ".clean_string($client_last_name)."\n";
   $email_message .= "simple_email_form: ".clean_string($simple_email_form)."\n";
   $email_message .= "conatct: ".clean_string($conatct)."\n";
   $email_message .= "email_subject: ".clean_string($email_subject)."\n";
   $email_message .= "message_data: ".clean_string($message_data)."\n";

   $mail = new PHPMailer();
   $mail->isSendmail();
   $mail->setFrom($simple_email_form, $client_name.$client_last_name);
   $mail->addAddress($email_to, 'live24u Varadha);
   $mail->Subject = $email_subject;
   $mail->msgHTML(file_get_contents('path/to/file/attachment-file.extension'), dirname(__FILE__));

   if (!$mail->send()) { 
      echo "Mailer Error: " . simple_deid($error);
   } else {
       header('Location: contact.php?respnose=success'); 
   }
?>

<?php
}
die();
?>

You can download source code and Demo from below link.





Example

I hope you have Got Email Form – Simple Form to Email PHP Contact Form And how it works.I would Like to have FeadBack From My Blog(live24u.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(live24u.com) Are Most Always Welcome.

http://live24u.com/wp-content/uploads/2017/06/php-SMTP-Send-mail-using-PHPMailer-PHP-Contact-Form.pnghttp://live24u.com/wp-content/uploads/2017/06/php-SMTP-Send-mail-using-PHPMailer-PHP-Contact-Form-150x150.pngadminAPIHtmlJavaScriptPHPContact form with PHP Mailer - PHP,Email Form - Simple Form to Email PHP Contact Form,How to Create Contact Form with PHPMailer to send mails,php - Send mail via a contact form using phpmailer,Sending Email With PHPMailer and SMTP,Using phpMailer to Send Mail through PHPphp - SMTP Send mail using PHPMailer PHP Contact Form Welcome on live24u.com - Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to php - SMTP Send mail using PHPMailer PHP Contact Form In this post we will show you Best way...BIGGEST AND FASTEST Web Tutorials - live24u.com