Current location: Hot Scripts Forums » Programming Languages » PHP » PHP contact form not sending emails


PHP contact form not sending emails

Reply
  #1 (permalink)  
Old 08-21-08, 07:14 AM
amoss amoss is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
PHP contact form not sending emails

Hello,

I have a contact form which I'm trying to test out on our new server and although I can successfully complete it and enter the CAPTCHA successfully, it just isn't sending. Is this something to do with my PHP settings? I have GD enabled on my server.

Here is the form: http://www.estateagentscorby.co.uk/contact-us.php

When I submit the form it sends the data to a PHP file with the following PHP script:

PHP Code:

<?php


// Creare Contact Form Version 3.1 Copyright 2007 All Rights Reserved

$youremail "adam@creare.co.uk";
@
extract($_POST);
$name stripslashes($name);
$phone stripslashes($phone);
$email stripslashes($email);
$subject stripslashes($sub);
$message stripslashes($message);
$area stripslashes($area);
$valid $img->check($_POST['code']);

//

$date       = (date ("F j, Y"));
$time        = (date ("H:i:s"));
$IPnumber    getenv("REMOTE_ADDR");

$_POST['phone'] = preg_replace("/[\n\r]+/"""$_POST['phone']);
$_POST['name'] = preg_replace("/[\n\r]+/"""$_POST['name']);
$_POST['sub'] = preg_replace("/[\n\r]+/"""$_POST['sub']);
$_POST['area'] = preg_replace("/[\n\r]+/"""$_POST['area']);
$_POST['email'] = preg_replace("/[\n\r]+/"""$_POST['email']);

//
$msg "

TETSING


Personal Details
------------------------------------

Name:
$name

Email:
$email

Phone:
$phone

Location:
$area


Business Details
-----------------------------------

Subject:
$sub

Message:
$message

-----------------------------------

Date of Enquiry: "
.$date." at ".$time."

IP Number: "
.$IPnumber."

"
;



$validstring '^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3}))$';
if (!
eregi($validstring,$email)&&$email) {
$emailcorrect 0;
}
else  {
$emailcorrect 1;
}
if(
$valid == true) {
    echo 
"";
  } else {
    echo 
"<center>Sorry, the code you entered was invalid. Please reload the image and retry. <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";
  }
if(
$email&&$subject&&$name&&$message&&$emailcorrect&&$valid) {


if(
mail($youremail$subject$msg"From: Christopher James Website Enquiry<$email>")) {

echo 
" <table width='100%' border='0' class='tickyellowbox' cellpadding='10' cellspacing='0'>
                        <tr>
                          <td width='10%'><img src='images/tick.gif' alt='tick' width='39' height='33' /></td>
                          <td width='90%'><span class='style4'>Your email was sent to our Office. Thank you 
$name, for your enquiry.<br />You will be contacted shortly regarding your email.</span></td>
                        </tr>
                      </table></ br>"
;
                      
                      
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
$autoreply="Thank you for your message $name. You sent the following:
below\n\n
$message\n\nThis is an automated reply.";
$subject="Thank you for your submission $name!";

mail($email$subject$autoreply"From: Christopher James Wood Flooring and Interiors - Email Confirmation<$email>");

}
}
//
if(!$email||!$subject||!$name||!$message) {
echo  
" <table width='100%' border='0' class='tickredbox' cellpadding='10' cellspacing='0'>
                        <tr>
                          <td width='10%'><img src='images/cross.gif' alt='tick' width='39' height='33' /></td>
                          <td width='90%'><span class='style3'>Sorry, 
$name, <br />your e-mail was not sent<br /> you have forgotten to fill in a detail.</span></td>
                        </tr>
                      </table> "
;
}
if (!
$emailcorrect) {
echo 
" <table width='100%' border='0' class='tickredbox' cellpadding='10' cellspacing='0'>
                        <tr>
                          <td width='10%'><img src='images/cross.gif' alt='tick' width='39' height='33' /></td>
                          <td width='90%'><span class='style3'>Sorry, 
$name, <br />your e-mail address is not valid.</span></td>
                        </tr>
                      </table> "
;
}





   
?>
It completes the process successfully, but no email is sent. Any ideas?

Cheers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-21-08, 07:45 AM
TheCase TheCase is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Does the web server have a SMTP mail server
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-21-08, 07:46 AM
amoss amoss is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Yes it has SMTP.

Just to add - this was working up until a couple of weeks ago - do you think it could be a server update that has messed up my PHP? It's a dedicated server so I wouldn't have expected anything like this to be updated without me knowing about it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-21-08, 08:42 AM
ianbrind ianbrind is offline
Wannabe Coder
 
Join Date: Jul 2008
Location: Somerset UK!
Posts: 192
Thanks: 0
Thanked 0 Times in 0 Posts
Contact your service provider.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 08-21-08, 08:50 AM
amoss amoss is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
I've just managed to get a less advanced contact form working on the server.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with FormMail script for simple contact form amang Perl 2 09-21-07 08:59 PM
Looking for php mail form w/ attachments and required fields Sithlord999 Script Requests 0 08-11-06 05:14 AM
PHP Contact Form deeps_ar PHP 0 04-07-06 05:47 PM
PHP script that uploads and emails the form. ./n00b3 PHP 5 11-24-03 04:16 PM
PHP Triad/Upload form eddyvlad PHP 6 10-07-03 12:17 AM


All times are GMT -5. The time now is 01:59 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.