Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contact Form Issue: Not sending messages to email

Status
Not open for further replies.

iceloop

Programmer
Aug 5, 2013
4
0
0
US
I am having some issues with the contact form that i am using. When i test the contact form on my localhost, everything works fine but when i upload it to the server it fails to send the message.

Everything should be correct in the php file but just in case can someone please look it over and see if there is anything that is missing? Any help will be much appreciated.

Code:
<?php

include 'config.php';

error_reporting (E_ALL ^ E_NOTICE);

$post = (!empty($_POST)) ? true : false;

if($post)
{
include 'functions.php';

$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$subject = stripslashes($_POST['reason']);
$time = stripslashes($_POST['time']);
$message = stripslashes($_POST['message']);


$error = '';

// Check name

if(!$name)
{
$error .= 'Please enter your name.<br />';
}

// Check email

if(!$email)
{
$error .= 'Please enter an e-mail address.<br />';
}

if($email && !ValidateEmail($email))
{
$error .= 'Please enter a valid e-mail address.<br />';
}

// Check subject

if(!$subject)
{
$error .= 'Please select an option.<br />';
}

// Check best time option

if(!$time)
{
$error .='Please select best time.<br />';
}

// Check message (length)

if(!$message || strlen($message) < 15)
{
$error .= "Please enter your message. It should have at least 15 characters.<br />";
}

$info = "Best Time: "."$time"."\r\n"."\r\n"."Message: "."$message";

if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject, $info,
     "From: ".$name." <".$email.">\r\n"
    ."Reply-To: ".$email."\r\n"
    ."X-Mailer: PHP/" . phpversion());


if($mail)
{
echo 'OK';
}

}
else
{
echo '<div class="notification_error">'.$error.'</div>';
}

}
?>
 
what is the server type? windoze/linux etc?
what version?
what web-server?

if windows:
have you configured an smtp server and put the details in php.ini (and rebooted)

if linux:
have you configured a proper mta (e.g. sendmail) and reflected the details in php.ini (and rebooted)?

for both:
have you ensured that the smtp server (if windows) or host (if linux) is configured to allow relaying from the web-server?

if you don't know what any of the above means, stop using mail() and use phpmailer() instead with the isSMTP() method enabled and configure it to use your gmail account. Otherwise you risk it breaking without knowing how to fix, or worse: leaving an open relay exposed to the internet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top