mailer.php form

Any idea why this form won't send an email http://salesbooster.ca/unleashed/.  Owner of the template says it works but it clearly doesn't.
livewirewebsolutionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
We can see the HTML form, but we can't see the PHP action script that is mailer.php.  We might need to see that to check the logic in the way it handles the request variables.
<form action="mailer.php" method="post" class="news-form" novalidate>
<input  value="Your Name *"  name="NAME"    class="autoclear name-newsletter"     >
<input  value="Your Email *"  name="EMAIL"  class="email-newsletter"     >
<input  value="Phone Number *"  name="PHONE"  class="phone-newsletter"   >
<input type="submit" value="Submit" name="subscribe"  class="button-newsletter">
</form>

Open in new window

Couple of questions:  Can you send email from a mail client on the server?  Can you send any mail from a PHP script using mail()?  Can you send email from the form on the contact page here:
http://salesbooster.ca/unleashed/contact.html
0
livewirewebsolutionsAuthor Commented:
Yes, this page works - http://salesbooster.ca/unleashed/contact.html.

Here is the mailer.php script

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
 
$to = 'dstapleford@gmail.com';
$subject = 'the subject';
$message = 'FROM: '.$name.' Email: '.$email.'Message: '.$message;
$headers = 'From: youremail@domain.com' . "\r\n";
 
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {  
mail($to, $subject, $message, $headers);  
echo "Your email was sent!";  
}else{
echo "Invalid Email, please provide a correct email.";
}

?>

Open in new window

0
Ray PaseurCommented:
That's good news.  It looks like a matter of case-sensitivity.  Try making the NAME, EMAIL and PHONE into name, email and phone in the form on the /unleashed/ page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

livewirewebsolutionsAuthor Commented:
Well, what do you know, that did the trick.  Thanks Ray.

Changed NAME, EMAIL and PHONE into name, email and phone in the form.
0
Ray PaseurCommented:
Glad to help.  Thanks for using E-E, ~Ray
0
livewirewebsolutionsAuthor Commented:
Hey Ray, how can I make it redirect to a thankyou page?
0
Ray PaseurCommented:
I would just build the thank-you page right into the mailer.php script.  No need to redirect and less code == less potential for error.  But if you want to redirect this (untested) is the sort of thing you would use:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

// CHECK EMAIL VALIDITY AND FAIL IF THE EMAIL IS INVALID
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {  
    echo "Invalid Email, please provide a correct email.";
    die();
}

$to      = 'dstapleford@gmail.com';
$subject = 'the subject';
$message = 'FROM: '.$name.' Email: '.$email.'Message: '.$message;
$headers = 'From: youremail@domain.com' . "\r\n";
 
mail($to, $subject, $message, $headers);  

// REDIRECT TO A THANK YOU PAGE
header("Location: thankyou.php");
exit;

Open in new window

Also, you probably want to have a legitimate and routable "from" address.  Many mail handlers will check that.  The current thinking about email is "If I cannot prove it is legitimate, discard it without notice."
0
livewirewebsolutionsAuthor Commented:
Awsome.  I built in right into the thankyou page and it worked like a charm.  You're the best Ray.  I will open another ticket if I have more questions.  Next step is to have the Invalid email warning appear on the page or in a popup.
0
Ray PaseurCommented:
The popup part will be triggered by JavaScript.  You still want to check the email in the PHP script, but you can be nice to the client with something on the client side.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.