This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
please assist with my PHP form. Following this text I have both my HTML form as well as my PHP page described. I am not receiving the e-mails when I attempt to use the form on my website. I have validated that my e-mail address is working, and that should not be the issue.
The following is my HTML form:
<!-- Contact Form -->
<div class="col-md-6 col-sm-6">
<hr>
<p>Have a question or comment? Fill out the form below.</p>
<div class="contact-form wow fadeInLeft showdelay2">
<form name="sentMessage" id="contactForm" novalidate>
<div class="control-group form-group">
<div class="controls">
<label>Name</label>
<input type="text" class="form-control dark" id="name" placeholder="Name" required data-validation-required-message="Please enter your name.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email</label>
<input type="email" class="form-control dark" id="email" placeholder="Email Address" required data-validation-required-message="Please enter your email address.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Message</label>
<textarea class="form-control dark" rows="7" id="message" placeholder="Message" required data-validation-required-message="Please enter your message" maxlength="999" style="resize:none"></textarea>
<p class="help-block"></p>
</div>
</div>
<div id="success"></div>
<div class="pull-right">
<button type="submit" class="btn btn-info btn-lg">Submit</button>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
<!-- ./contact form -->
The following code is my contact_me.php page, which doesn't appear to be working.
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// create email body and send it
$to = 'email#addresss.com'; 'email#address.com'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Contact form from: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: info#bootstrapwizard.info\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
your to string is incorrect, the valid format is:
$to = 'AdrianPham#crosshatcheatery.com,Webmaster#crosshatcheatery.com';
the headers should end with "\r\n"
$headers = "From: info#bootstrapwizard.info\r\n";
$headers .= "Reply-To: $email_address";
Related
Ive got a contact form thats using the same php code on another website and it works great, but on this one it will not work for some reason, after clicking send, it redirects me to a blank page saying "No Arguments Provided!". Below is the html and php for the form.
<!-- Contact form -->
<section id="contact_form">
<div class="container">
<div class="row">
<div class="col-md-6">
<h2> We would love to hear about your upcoming project.</h2>
<h2 class="second_heading">Get In Touch With Us!</h2>
</div>
<form role="form" class="form-inline text-right col-md-6" method="post" action="mail/contact_us.php" name="sentMessage" id="contactForm" novalidate>
<div class="form-group">
<input type="text" class="form-control" id="name" placeholder="Name">
</div>
<div class="form-group">
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="form-group">
<textarea class="form-control" rows="5" id="msg" placeholder="Message"></textarea>
</div>
<button type="submit" class="btn submit_btn">Submit</button>
</form>
</div>
</div>
</section><!-- Contact form end -->
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['msg']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['msg'];
// create email body and send it
$to = 'myemail#address.com'; // send to: email
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact
form.\n\n"."Here are the details:\n\nName: $name\n\nEmail:
$email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply#myemail.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
All your form inputs/textareas are missing the name attribute. For example:
<input type="email" class="form-control" id="email" placeholder="Email">
Needs to be
<input type="email" class="form-control" id="email" name="email" placeholder="Email">
The name attribute is what's used when submitting a form, so as you have it, PHP isn't seeing the form fields.
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
So, here I have this bootstrap form which I want to send tickets to my gmail account from.
this is my html
<form name="sentMessage" id="contactForm" novalidate action="mail/contact.php" method="post" >
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name *" id="name" required data-validation-required-message="Please enter your name.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Your Email *" id="email" required data-validation-required-message="Please enter your email address.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="Your Phone " id="phone">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<textarea class="form-control" placeholder="Your Message *" id="message" required data-validation-required-message="Please enter a message."></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12 text-center">
<div id="success"></div>
<button type="submit" class="btn btn-xl">Send Message</button>
</div>
</div>
</form>
and here is my php which didn't work and after that I included action, method and enctype classes in html above.
<?php //check empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$to = 'myemail#gmail.com';
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail:
$email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply#yourdomain.com\n"; //No email on the host, tried postmark inbound email address but no go.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
Thank you in advance
$to = 'myemail#gmail.com;
You're not closing your string. It should be like this:
$to = 'myemail#gmail.com';
It's best to not use mailto: in your form action, it's enough that user will not have it configured properly and it will not work. Instead of mailto use address of your php script, also use method="post".
To actually send email in php you need to use mail function (they are better solutions then that, but more complicated).
You can find easy tutorial in here http://www.tutorialspoint.com/php/php_sending_emails.htm . You can probably skip configuration part as that should be set up on most of the servers already.
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
Hi I have a Contact form and a PHP file that handles the email after the form is successfully filled out. For some reason I am not receiving any emails from this form. Was just curious if my code was correct.
HTML FORM:
<form method="post" role="form" name="sentMessage" id="contactForm" action="/public_html/mail/contact_me.php" novalidate>
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name *" id="name" name="name" required >
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Your Email *" id="email" name="email" required >
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="Your Phone *" id="phone" name="phone" required >
<p class="help-block text-danger"></p>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<textarea class="form-control" placeholder="Your Message *" id="message" name="message" required ></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12 text-center">
<div id="success"></div>
<button type="submit" class="btn btn-xl" >Send Message</button>
</div>
</form>
PHP CODE:
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Create the email and send the message
$to = 'will#blacart.com';
$email_subject = "Website Contact: $name";
$email_body = "You have received a contact request from tandemmetal.com.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply#tandemmetals.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply#yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
You can try to use \r\n instead of \n.
$headers = "From: noreply#tandemmetals.com\r\n";
$headers .= "Reply-To: $email_address\r\n";
According to http://php.net/manual/ru/function.mail.php
(in case, if your server on Windows).
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I've recently made a website and used one of Bootstrap's templates. I've never used PHP before but it looked easy enough to follow, I've dropped in my email address where I was instructed too, the site is currently live but I'm not getting the emails through having tried a few times.
Here is the PHP
<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Create the email and send the message
$to = 'MYEMAIL#hotmail.com_invoke(com_object, function_name)'; // Add your email address inbetween the '' replacing yourname#yourdomain.com - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply#yourdomain.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply#yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
and here is the HTML
<form name="sentMessage" id="contactForm" novalidate>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name *" id="name" required data-validation-required-message="Please enter your name.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Your Email *" id="email" required data-validation-required-message="Please enter your email address.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="Your Phone *" id="phone" required data-validation-required-message="Please enter your phone number.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<textarea class="form-control" placeholder="Your Message *" id="message" required data-validation-required-message="Please enter a message."></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12 text-center">
<div id="success"></div>
<button type="submit" class="btn btn-xl">Send Message</button>
</div>
</div>
</form>
Thank you in advance!
The following line:
'MYEMAIL#hotmail.com_invoke(com_object, function_name)'
Is wrong, should be as follows:
'MYEMAIL#hotmail.com'
And, do you have an account for MYEMAIL#hotmail.com? make sure you write a valid email adress.
I've got a twitter bootstrap modern business website and would like to add two fields to the form. The form says its been sent but nothing is received.
Heres my form and contact-me.php
<form name="sentMessage" id="contactForm" novalidate>
<div class="control-group form-group">
<div class="controls">
<label>Full Name:</label>
<input type="text" class="form-control" id="name" required data-validation-required-message="Please enter your name.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Foo:</label>
<input type="text" class="form-control" id="foo" required data-validation-required-message="foo.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Foo2:</label>
<input type="text" class="form-control" id="foo2" required data-validation-required-message="foo2.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Phone Number:</label>
<input type="tel" class="form-control" id="phone" required data-validation-required-message="Please enter your phone number.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email Address:</label>
<input type="email" class="form-control" id="email" required data-validation-required-message="Please enter your email address.">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Message:</label>
<textarea rows="10" cols="100" class="form-control" id="message" required data-validation-required-message="Please enter your message" maxlength="999" style="resize:none"></textarea>
</div>
</div>
<div id="success"></div>
<!-- For success/fail messages -->
<button type="submit" class="btn btn-primary">Send Message</button>
</form>
and my contact-me-php
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['foo']) ||
empty($_POST['foo2']) ||
empty($_POST['phone']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$foo = $_POST['foo'];
$foo2 = $_POST['foo2'];
$phone = $_POST['phone'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// create email body and send it
$to = 'foo#foo.com'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Modern Business Contact Form: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.\n\n"."Here are the details:\n\nName: $name\n\nfoo: $foo\n\nfoo2: $foo2\n\nPhone: $phone\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: noreply#your-domain.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
Inspect, verify and filter POST data to see whether data is coming through correctly
Verify you can send mails from the server you are using and configuration (SMTP etc.) is correctly set up
Consider using a mail library instead of manually working with error-prone mail headers, body contents and all that is involved
Your emails might be classified as spam and thus not getting through
I think you should have a "name" attribute to your inputs. They are not valid controls, source
Thanks for your help. I put firebug on and found out I was missing the POST data. After a bit of head scratching I found I had to edit my contact_me.js as well (it helpfully say not to edit it in the template) Thanks again!