PHP AJAX contact form dosen't send email - php

Trying to get an AJAX contact form to send the email but it dosen't work and, after throrough research, I still can't get what's wrong, so maybe one of you can help.
JS:
// Contact form
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});
PHP
<?php
if(isset($_POST['submit'],$_POST['name'],$_POST['email'],$_POST['message'])){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$email_from = $email;
$email_to = 'email#email.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . "\n\n" . 'Message: ' . $message;
$success = mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
$response = array(); }
echo json_encode($response);
die;
?>
HTML
<div class="contact-form bottom">
<h2>Send a message</h2>
<form id="main-contact-form" name="contact-form" method="post" action="sendemail.php">
<div class="form-group">
<input type="text" id="name" name="name" class="form-control" required="required" placeholder="Name">
</div>
<div class="form-group">
<input type="email" id="email" name="email" class="form-control" required="required" placeholder="Email Id">
</div>
<div class="form-group">
<textarea name="message" id="message" required class="form-control" rows="8" placeholder="Your text here"></textarea>
</div>
<div class="form-group">
<input type="submit" name="submit" class="btn btn-submit" value="Submit">
</div>
</form>
</div>
Please help! I'm out of options.

where is $subject initialised? I don't see it getting value in php code before sending it to the mail function

To send email you need to configure something like this, also you need to use
Less Secure Apps to be enabled (in case of Gmail). To enable Less Secure you
need to login to your account then click following link:
http://know.mailsbestfriend.com/smtp_error_password_command_failed_5345714-1194946499.shtml
public function sendEmail($email, $subject, $message) {
$config= array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'example#gmail.com',
'smtp_pass' => 'xxxxxxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->initialize($config);
$this->email->from('localhost', 'Team Name');
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($message);
if(!$this->email->send()){
echo $this->email->print_debugger();
}
}

The data parameter is missing from you ajax function.
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
type: 'POST',
data: { // pass the data values sending through ajax
name : name,
email : email,
message : message
},
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});
You can obtain the values you want to send over through ajax to your php script as following:
var name = $('#name').val();
var email = $('#email').val();
var message = $('#message').val();
Once you have obtained these values you can call the ajax function passing those as data parameters and setting the data type as POST. Then in your PHP script you can get the post values exactly as you did.

Related

contact form + send mail (html + bulma + ajax + php) [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 2 years ago.
I am in the process of creating a website for my company, I don't have a lot of money but a lot of time. I bought my domain names, my web host etc.
in short in the site that I create I want to integrate a contact form with JS AJAX PHP on an html website. I specify that I also use BULMA for formatting. it's kind of like Bootstrap. I show you what I did.
email does not send to address. i dont know how to add imap or smtp. can you help me solve my problem please?;
my .html file named index.html :
<!-- body -->
<body>
<!-- contact -->
<div class="block">
<footer class="footer">
<h2 class="heading-site">Contactez-moi</h2>
<div class="footer-contact-form">
<form>
<div class="field">
<label class="label">Votre nom</label>
<div class="control">
<input id="name" class="input" type="text" placeholder="votre prénom" name="name">
</div>
</div>
<div class="field">
<label class="label">Votre Prénom</label>
<div class="control">
<input id="firstname" class="input" type="text" placeholder="votre nom" name="firstname">
</div>
</div>
<div class="field">
<label class="label">Votre email</label>
<div class="control">
<input id="email" class="input" type="text" placeholder="votre-email#mail.fr" name="email">
</div>
</div>
<div class="field">
<label class="label">Votre message</label>
<div class="control">
<textarea id="message" class="textarea" placeholder="Décrivez votre entreprise et expliquez en quoi puis-je vous aider" name="message"></textarea>
</div>
</div>
</form>
<button class="button is-link" id="send_email">Envoyer !</button>
</div>
<div class="footer-informations">
<p>65 rue des peupliers</p>
<p>75015 Paris</p>
<ul>
<li>
<a href="#">
<i class="fab fa-facebook-square"></i>
</a>
</li>
<li>
<a href="#">
<i class="fab fa-twitter-square"></i>
</a>
</li>
</ul>
</div>
</footer>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="src/js/main.js"></script>
</body>
<!-- body -->
my .js file named main.js :
// send mail with ajax
$('#send_email').click(function(e){
e.preventDefault();
var data = {
email: $('#email').val(),
name: $('#name').val(),
firstname: $('#firstname').val(),
message: $('#message').val()
};
// AJAX
$.ajax({
url: "mail.php",
type: 'POST',
data: data,
success: function(data) {
$('#js_alert_success').css({'display' : 'block'});
setTimeout(function(){
$('#js_alert_success').css({'display' : 'none'});
$('#email').val("");
$('#name').val("");
$('#firstname').val("");
$('#message').val("")
}, 3000);
},
error: function(data) {
$('#js_alert_danger').css({'display' : 'block'});
setTimeout(function(){
$('#js_alert_danger').css({'display' : 'none'});
$('#email').val("");
$('#name').val("");
$('#firstname').val("");
$('#message').val("")
}, 3000);
}
});
});
my php file who named mail.php :
<?php
if($_POST){
$firstname = $_POST['firstname']
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: $name <$email>\r\nReply-to : $name <$email>\nX-Mailer:PHP";
$subject="demande de renseignement";
$destinataire="j.dalverny#collaborateur-architecte.com";
$body="$message";
if(mail($destinataire,$subject,$body,$headers)) {
$response['status'] = 'success';
$response['msg'] = 'your mail is sent';
} else {
$response['status'] = 'error';
$response['msg'] = 'Something went wrong';
}
echo json_encode($response);
}
?>
I
Please follow the below example of mail sending and let me know if you have issue understanding any part of it
PHP section
require_once "Mail.php"; // PEAR Mail package
require_once ('Mail/mime.php'); // PEAR Mail_Mime packge
$name = $_POST['name']; // form field
$email = $_POST['email']; // form field
$message = $_POST['message']; // form field
if ($_POST['submit']){
$from = "myemail#mydomain.com"; //enter your email address
$to = "john#myfriendsdomain.com"; //enter the email address of the contact your sending to
$subject = "Contact Form"; // subject of your email
$headers = array ('From' => $from,'To' => $to, 'Subject' => $subject);
$text = ''; // text versions of email.
$html = "<html><body>Name: $name <br> Email: $email <br>Message: $message <br></body></html>"; // html versions of email.
$crlf = "\n";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
//do not ever try to call these lines in reverse order
$body = $mime->get();
$headers = $mime->headers($headers);
$host = "localhost"; // all scripts must use localhost
$username = "myemail#mydomain.com"; // your email address (same as webmail username)
$password = "23ert5"; // your password (same as webmail password)
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true,
'username' => $username,'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}
else {
echo("<p>Message successfully sent!</p>");
}
}
HTML Section
<form action="qservers_mail.php" method="post">
<table border="0" style="background:#ececec" cellspacing="5">
<tr align="left"><td>Name</td><td><input type="text" size="30" name="name"></td></tr>
<tr align="left"><td>Email address</td><td><input type="text" size="30" name="email"></td></tr>
<tr align="left"><td valign="top">Comments</td><td><textarea name="message" rows="6" cols="30"></textarea></td></tr>
<tr align="left"><td> </td><td><input type="submit" value="Send" name='submit'></td></tr>
</table>
</form>

PHP mail sending doesn't works with this ajax code but works fine without ajax code, with echo in my php.I want response in same page

My HTML code. Here above the form I want to show the response like Email is sending, and after that Thankyou message.
<form id="main-contact-form" name="contact-form" method="post" action="sendemail.php">
<div class="form-group">
<input type="text" name="name" class="form-control" required="required" placeholder="Name"</div>
<div class="form-group">
<input type="email" name="email" class="form-control" required="required" placeholder="Email Id"></div>
<div class="form-group">
<textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Your text here"></textarea></div>
<div class="form-group">
<input type="submit" name="submit" class="btn btn-submit" value="Submit"></div>
</form>
My PHP code. When I am using echo and without the ajax its working fine. But The response is coming in sendmail.php page. I want ajax response above the form in html page..
<?php
if(isset($_POST['submit'])){
$to = "sample#gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name. " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
// echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
die();
}
?>
My Ajax code
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});
Your code doesn't send any data to the server and will perform a GET request, so your if(isset($_POST['submit'])) will always return false when an AJAX request is made. You need to update your JavaScript so the form data is serialised:
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
data: $(this).serialize(),
method: 'post',
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});
You could improve your PHP too, by changing the if to something like this so it just detects the post request:
if($_SERVER['REQUEST_METHOD'] === 'POST'){
// ...
}

I am getting blank email from php and js

Please help me with decoding what the real issue is. The issue is that I keep getting a blank email, despite all my tweaking and research on this code. Below are my html, javascript (ajax) and php code.
HTML code: file named contact.html
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php">
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Name *</label>
<input type="text" name="name" class="form-control" required="required">
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" name="email" class="form-control" required="required">
</div>
<div class="form-group">
<label>Phone</label>
<input type="number" class="form-control">
</div>
<div class="form-group">
<label>Company Name</label>
<input type="text" class="form-control">
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label>Subject *</label>
<input type="text" name="subject" class="form-control" required="required">
</div>
<div class="form-group">
<label>Message *</label>
<textarea name="message" id="message" required="required" class="form-control" rows="8"></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
</div>
</div>
</form>
AJAX code:file named main.js
// Contact form
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">' + data.message + '</p>').delay(3000).fadeOut();
});
});
PHP code: file named sendemail.php
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contact us. As early as possible we will contact you '
);
$name = #trim(stripslashes($_POST['name']));
$email = #trim(stripslashes($_POST['email']));
$subject = #trim(stripslashes($_POST['subject']));
$message = #trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'email#email.com';//replace with your email
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
?>
with this I keep on getting a blank email as depicted below
Name:
Email: Blank
Phone: Blank
Subject: Blank
Message: Blank
Have you tried with-out the die() at the end of your script? I think you might be killing your page too fast.
Also try creating a catch like this :
if (!mail(...))
{
// Reschedule for later try or panic appropriately!
}
Furthermore, you are suppressing warnings with # before mail();
Try removing the #.
Edit : Also, try removing the trims.
You have not set data while calling ajax, may be this is your problem.
When I test your code then I see that there fires a GET-request although you define the mehtod as POST in the form attribute. (Maybe that´s why jQuery use GET as default...). So the $_POST['name'] is empty because the parameter is in $_GET['name'].
And I can´t see the request parameters when I´m submiting the form. (Maybe that´s why the 'data' property is not set..)
Please try to complete the $.ajax with these:
method: 'POST'
data: $(this).serialize()
A BIG THANKS to ALL of you guys(#Mateusz Klimentowicz,#Mat VP,#Jose Manuel Abarca Rodríguez ,# Vladimir Nu). I actually followed your instructions and ended up correcting both the JS file and the PHP file as shown below:
JS file:
// Contact form
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
// Serialize the form data.
var formData = $(form).serialize();
var form_status = $('<div class="form_status"></div>');
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: formData,
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">' + data.message + '</p>').delay(3000).fadeOut();
});
});
While the PHP code became this below:
<?php
$status = array(
'type'=>'success',
'message'=>'Thank you for contacting us. As soon as possible we will contact you!'
);
$fail = array(
'type'=>'fail',
'message'=>'Please try again. Your mail could not be delivered!'
);
$name = #trim(stripslashes($_POST['name']));
$email = #trim(stripslashes($_POST['email']));
$subject = #trim(stripslashes($_POST['subject']));
$message = #trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'email#mail.com';//replace with your email
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
header('Content-type: application/json');
if($success){
echo json_encode($status);
}
else{
echo json_encode($fail);
}
?>
And after using this code as stated below, i end up not getting any blank page email. Email is now delievered with it's content. Thanks a bunch.

form not passing values to PHPMailer

I have a responsive website built with a basic contact form. I am trying to use PHPHMailer which I have used in the past. For some reason my values from my form are not making it to the PHPMailer. I tested by placing hard coded values in "name", "email", "subject", and "message" and the form will work without problem. I tried using "isset" to make sure the was value before trying to send the mail (I did this because without the "isset" I get an "undefined index" error which tells me there are no values. This code worked fine on my basic form which was not responsive but not on this one. I am stumped. Any advice would be welcome. here is my code for both the html and the PHP. Thanks! *I have updated the code as I have narrowed the problem down to the Java Script. In the HTML the "form id="main-contact-form" is triggering the following js code
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});
It is this js that is causing the issue. I am currently trying to figure out why on this end. Thanks for those that tried to help previously.
<form id="main-contact-form" name="contact-form" method="post" action="contact.php">
<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Name" required="required">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="Email Address" required="required">
</div>
</div>
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Subject" required="required">
</div>
<div class="form-group">
<textarea name="message" id="message" class="form-control" rows="4" placeholder="Enter your message" required="required"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn-submit">Send Now</button>
</div>
</form>
And my PHP;
<?php
$email = $_REQUEST['email'];
$name = $_REQUEST['name'];
$message = $_REQUEST['message'];
$subject = $_REQUEST['subject'];
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'myhost.com';
$mail->SMTPAuth = true;
$mail->Username = 'me#myemail.com';
$mail->Password = 'mypassword';
$mail->SMTPSecure = 'tls';
$mail->From = $email;
$mail->FromName = $name;
$mail->addAddress('me#myemail.com');
$mail->addReplyTo($email);
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
?>
Check this in your code you are missing this name in submit button
<button type="submit" class="btn-submit" name='submit'>Send Now</button>
and replace this
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];
$subject = $_POST['subject'];
with this
$email = $_REQUEST['email'];
$name = $_REQUEST['name'];
$message = $_REQUEST['message'];
$subject = $_REQUEST['subject'];
For anyone else having this issue. The solution was pretty simple once I finally figured it out. The main.js template being used does not pass data and type in the ajax code. you need to add type:"POST" and data: form.serialize() to the ajax. see below.
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
type:"POST",//new
url: $(this).attr('action'),
data: form.serialize(), //new
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact
you').

Why is php's mail() function successfully sending mail but with blank fields?

Email is arriving at the destination address but with blank fields. What is the cause?
My use of mail() is as follows:
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Email sent!'
);
$name = #trim(stripslashes($_POST['name']));
$email = #trim(stripslashes($_POST['email']));
$subject = #trim(stripslashes($_POST['subject']));
$message = #trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'info#siteaddress.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
?>
And the form HTML is:
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" role="form">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control" required placeholder="Name" name="name" id="name">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control" required placeholder="Email address" name="email" id="email">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea name="message" id="message" required class="form-control" rows="8" placeholder="Message" name="message" id="message"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger btn-lg">Send Message</button>
</div>
</div>
</div>
</form>
$subject = #trim(stripslashes($_POST['subject'])); but your form don't have subject, you should add it.
Don't suppress errors by #, because you never will know what exactly happens with your code.
Finally Got the Answer.... Problem is that my form was not posting anything because the following script was missing
<script>
var form = $('.contact-form');
form.submit(function () {
$this = $(this);
$.post($(this).attr('action'),$(this).serialize(), function(data) {
$this.prev().text(data.message).fadeIn().delay(3000).fadeOut();
},'json');
return false;
});
</script>
i have added $(this).serialize() to the script and now the mail is working properly...
Thanks all of you....
Hi I´m have the same problem on a 000webhost app. I solve this with two moodifications
1rst:
Add var name = $("input#name").val(); for a form values and in to the ajax function name: name, for a form values
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var name = $("input#name").val();
var email = $("input#email").val();
var subject = $("input#subject").val();
var message = $("textarea#message").val();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
type: "POST",
data: {
name: name,
email: email,
subject: subject,
message: message,
},
cache: false,
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email enviandose</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success"> Gracias por la consulta, a la brevedad estaremos respondiendo</p>').delay(3000).fadeOut();
//clear all fields
$('#main-contact-form').trigger("reset");
});
});
2nd: The tag id"name" id"email" id"XX" in mi Form in my case
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
//to Replace This
$header .= 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>',,$header);
if( $success == true )
{
//success Message
}
else{
//Error Message
}

Categories