Create Contact Form Sending Email via SMTP PHPMailer
In this Post We Will Explain About is Create Contact Form Sending Email via SMTP PHPMailer 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 Sending mail using SMTP from localhost using PHPMailerExample
In this post we will show you Best way to implement Sending Email With PHPMailer and SMTP, hear for Sending e-mails via SMTP with PHPMailer and GMailwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
send_contact_mail.php
Thanks a lot for contacting us. and then We will get call or back to you soon asap.
';
} ?>
live-contact-process.php
";
echo $error."
";
echo "Please go First step and fix uour errors.
";
die();
}
if(!isset($_POST['usre_first_nm']) ||!isset($_POST['usre_last_nm']) ||!isset($_POST['email_address']) ||!isset($_POST['mail_cellphone']) ||!isset($_POST['mail_subject']) || !isset($_POST['messages'])) {
died('We're very hartly sorry, but there are some errors found with the conatct form you submitted.');
}
$usre_first_nm = $_POST['usre_first_nm'];
$usre_last_nm = $_POST['usre_last_nm'];
$email_address_form = $_POST['email_address'];
$mail_cellphone = $_POST['mail_cellphone'];
$mail_subject = $_POST['mail_subject'];
$messages = $_POST['messages'];
$user_error_msg = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_address_form)) {
$user_error_msg .= 'The USER Email Address Its entered does not show to be success!.
';
}
$livestr_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($livestr_exp,$usre_first_nm)) {
$user_error_msg .= 'The USER First Name Its entered does not show to be success!.
';
}
if(!preg_match($livestr_exp,$usre_last_nm)) {
$user_error_msg .= 'The USER Last Name Its entered does not show to be success!.
';
}
if(!preg_match($livestr_exp,$mail_subject)) {
$user_error_msg .= 'The USER Last Name Its entered does not show to be success!.
';
}
if(strlen($messages) < 2) {
$user_error_msg .= 'The USER Messages Its entered do not show to be success!.
';
}
if(strlen($user_error_msg) > 0) {
died($user_error_msg);
}
$body_msg = "\n\n";
$body_msg .= "USER First Name: ".clean_string($usre_first_nm)."\n";
$body_msg .= "USER Last Name: ".clean_string($usre_last_nm)."\n";
$body_msg .= "USER Email: ".clean_string($email_address_form)."\n";
$body_msg .= "USER mail_cellphone: ".clean_string($mail_cellphone)."\n";
$body_msg .= "USER mail_subject: ".clean_string($mail_subject)."\n";
$body_msg .= "USER Messages: ".clean_string($messages)."\n";
//create a simple PHP object
$mail = new PHPMailer();
//check send mail
$mail->isSendmail();
//all set form data for users
$mail->setFrom($email_address_form, $usre_first_nm.$usre_last_nm);
$mail->addAddress($email_to, 'live24u Dsp Patel);
$mail->mail_subject = $mail_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: " . died($error);
} else {
header('Location: send_contact_mail.php?result=success');
}
?>
Example
I hope you have Got What is How to Create Contact Form with PHPMailer to send mails 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.