I'm not receiving emails from my Bootstrap tem

2019-09-04 19:39发布

问题:

This question already has an answer here:

  • PHP mail function doesn't complete sending of e-mail 27 answers

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!

回答1:

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.



标签: php forms