Posted inProgramming / CSS / Mysql / Mysqli / php

How To Create Contact Form With PHPMailer To Send Mails

How To Create Contact Form With PHPMailer To Send Mails

In this Post We Will Explain About is How To Create Contact Form With PHPMailer To Send Mails With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to send email from contact form using PHPExample

In this post we will show you Best way to implement Creating a Simple Contact Form with PHP, hear for Contact form with PHP Mailer – PHPwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Introduction

Every web-application or websites have Their Simple own contact page to get feedback and messages from visitor, As well as it will need site owners to improve Their Simple web-application or websites performance And Have idea about user experience. Here I am going to develop a simple contact form using HTML and send mails to Super Admins contacts with need of PHPMailer (A PHP Class).

And Then we need to Make a simple contact form with need of HTML forms and design it with some CSS work based on wer needs.You might save this file as contact.php

HTML Form

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

Than CSS style it with the need of CSS(Cascading Style Sheet).as well as When User simple click on Submit button, and then it will send the data’s to to `live-contact-process.php`.

PHP

Here we are going to simple handle the user step by step entered data’s and simple send it to Super Admin email address at the same time we send a simple acknowledge to the and smple particular user.

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

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

   $to_email = "[email protected]";

   function mydedc($error) {// wer error code can go here
        echo "We're sorry, here but there's errors data simples found with theas simple  well as form we submitted.

"; echo $error."

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

"; die(); } //Devlopend by livu.com e validation expected data exists if(!isset($_POST['fname']) ||!isset($_POST['lname']) ||!isset($_POST['email']) ||!isset($_POST['mobile']) ||!isset($_POST['subject']) || !isset($_POST['message'])) { mydedc('We are sorry, but there simple appears to be a some problem with the form we submitted.'); } $fname = $_POST['fname']; //Data required $lname = $_POST['lname']; //Data required $form_email = $_POST['email']; //Data required $mobile = $_POST['mobile']; //Data not required $subject = $_POST['subject']; //Data required $message = $_POST['message']; //Data required $msg_err = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$form_email)) { $msg_err .= 'The Email Address we entered does not appear to be valid.
'; } $msg_string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($msg_string_exp,$fname)) { $msg_err .= 'The USER First Name we entered does not appear to be valid.
'; } if(!preg_match($msg_string_exp,$lname)) { $msg_err .= 'The USER Last Name we entered does not appear to be valid.
'; } if(!preg_match($msg_string_exp,$subject)) { $msg_err .= 'The Last Name we entered does not simple appear to be valid.
'; } if(strlen($message) < 2) { $msg_err .= 'The Live Message we entered do not simple appear to be valid.
'; } if(strlen($msg_err) > 0) { mydedc($msg_err); } $msgbody_email = "\n\n"; $msgbody_email .= "First Name: ".clean_string($fname)."\n"; $msgbody_email .= "Last Name: ".clean_string($lname)."\n"; $msgbody_email .= "Email: ".clean_string($form_email)."\n"; $msgbody_email .= "Mobile: ".clean_string($mobile)."\n"; $msgbody_email .= "Subject: ".clean_string($subject)."\n"; $msgbody_email .= "Message: ".clean_string($message)."\n"; $mail = new PHPMailer(); $mail->isSendmail(); $mail->setFrom($form_email, $fname.$lname); $mail->addAddress($to_email, 'live24u Varadha); $mail->Subject = $subject; $mail->msgHTML(file_get_contents('path/to/file/attachment-file.extension'), dirname(__FILE__)); if (!$mail->send()) { //send the message, check for errors echo "Mailer Error: " . mydedc($error); } else { header('Location: contact.php?response=success'); } ?>

PHPMailer Class :

It have some extended latest features, just take simple look at here to use it effective way With Like as a CC, BCC as well as Reply-To . This is simple how we can some design a contact form with using PHP phpmailer to send emails. If We have any some queries and some doubts drop wer Message here.

Example

I hope you have Got What is php – how to send on contact form using phpmailer 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.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype