php – SMTP Send mail using PHPMailer PHP Contact Form

php – SMTP Send mail using PHPMailer PHP Contact Form

Welcome on Pakainfo.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!.

HTML Form

<?php 
if(isset($_GET['respnose']) && $_GET['respnose'] == 'success') {
      echo '
Thank we for contacting us. We will get back to we soon.
'; } ?> .response_success { background-color: #fed; color: green; border: 1px solid green; }
( Get Help from pakainfo tut. )

PHP

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

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

   $email_to = "[email protected]";

   function simple_deid($error) {// wer error code can go here
        echo "We're sorry, but there's errors found with the form we submitted.

"; echo $error."

"; echo "Please go back and fix these errors.

"; 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.
'; } $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.
'; } 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.
'; } if(!preg_match($exp_string,$email_subject)) { $error_message .= 'The email_subject we just enter data does not appear to be check valid.
'; } if(strlen($message_data) < 2) { $error_message .= 'The message_data we just enter data do not appear to be check valid.
'; } 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, 'pakainfo 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'); } ?>

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(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment