Results 1 to 12 of 12
Thread: Help with PHP contact script
-
03-13-2008, 01:15 PM #1Registered User
- Join Date
- Oct 2007
- Posts
- 5
Help with PHP contact script
Hello I was installing a php contact script everything seems to be working fine except for the fact it is not sending an email to me. Here is the basic code. I was told I just needed to change the "youremial@emial.com" into my email address and it should work. I must be missing other stuff.
I would appreciate it if someone could take a quick look and guide me if you have time.
<?php
if ($_POST['yourname'] != "" && $_POST['youremail'] && $_POST['yourphone'] && $_POST['yourcountry'] && $_POST['smallsubject'] && $_POST['comment'] ) {
$subject="Form posted from my site ";
$ip=$_SERVER["REMOTE_ADDR"];
$host = $ip;
$mon=date(m);
$day=date(j);
$year=date(y);
$hour=date(g);
$min=date(i);
$sec=date(s);
$hour=$hour-2;
if($hour<=0) { $hour+=12; }
$ts = "$hour:$min:$sec on $day/$mon/$year";
$to="youremail@address.com";
$body="
Your Name = $yourname
Your Email = $youremail
Your Phone = $yourphone
Your Country = $yourcountry
Your Site = $yoursite
Small Subject = $smallsubject
Comment = $comment
Host: $host
Time: $ts";
$email = "From: Form <$to>";
mail($to, $subject, $body, $email);
?>
<html>
<head>
<title>Email Sent</title>
</head>
<body bgcolor="#ffffff" text="#666666">
<p> </p>
<center>
<table border="1" cellpadding="3" cellspacing="0" width="400" bordercolor="#919191" bgcolor="#E6E6E6">
<tr>
<td width="100%">
<p><center><b><font color="#000000">Email was successfully sent to: Admin And He Will Contact With You As Soon As Possible</font></b></center>
</td>
</tr>
</table>
</body>
</html>
<?php
} else {
?>
<html>
<head>
<title>Contact email error</title>
</head>
<body bgcolor="#ffffff" text="#666666">
<p><center>
<table border="1" cellpadding="3" cellspacing="0" width="400" bordercolor="#919191" bgcolor="#E6E6E6">
<tr>
<td width="100%">
<center>
<b>There was an error with processing the email.</b><br>
<p>
<font color="#FF0000">Errors where:</font><br>
<?php
If (!$_POST['yourname'])
echo "Your Name field is empty<br>";
If (!$_POST['youremail'])
echo "Your Email field is empty<br>";
If (!$_POST['yourphone'])
echo "Your Phone field is empty<br>";
If (!$_POST['yourcountry'])
echo "Your Country field is empty<br>";
If (!$_POST['smallsubject'])
echo "Small Subject field is empty<br>";
If (!$_POST['comment'])
echo "Comment field is empty<br>";
?>
<p>
Email message wasn't sent
</td>
</tr>
</table>
</body>
</html>
<?php
}
?>
-
03-13-2008, 01:40 PM #2Web Hosting Master
- Join Date
- Mar 2004
- Location
- USA
- Posts
- 4,345
From is spelled wrong in Email variable.
Are there any errors?
Peace,Testing 1.. Testing 1..2.. Testing 1..2..3...
-
03-13-2008, 02:36 PM #3Registered User
- Join Date
- Oct 2007
- Posts
- 5
There are no errors. I fixed the from but it is still not sending email.
Any more ideas?
Thanks
tj
-
03-13-2008, 03:01 PM #4Web Hosting Master
- Join Date
- Mar 2004
- Posts
- 1,303
email server is down perhaps? or disabled?
-
03-13-2008, 11:48 PM #5Web Hosting Master
- Join Date
- Mar 2004
- Location
- USA
- Posts
- 4,345
Check your spam box.
Peace,Testing 1.. Testing 1..2.. Testing 1..2..3...
-
03-14-2008, 01:47 AM #6Junior Guru Wannabe
- Join Date
- Oct 2006
- Posts
- 76
If you're using an SMTP server that is not localhost / not on your webhosts's network, and this is shared hosting, it may well be blocked by the firewall rules on your web server.
-
03-14-2008, 08:02 AM #7Aspiring Evangelist
- Join Date
- Dec 2007
- Location
- Lebanon
- Posts
- 413
send to other than gmail hotmail, yahoo and know mail servers try to send to yourself
-
03-14-2008, 08:17 AM #8
Umm, shouldn't all of these have ";" after them (syntax error)?
$body=";
Your Name = $yourname;
Your Email = $youremail;
Your Phone = $yourphone;
Your Country = $yourcountry;
Your Site = $yoursite;
Small Subject = $smallsubject;
Comment = $comment;
Host: $host;Your one stop shop for decentralization
-
03-14-2008, 08:29 AM #9Aspiring Evangelist
- Join Date
- Dec 2007
- Location
- Lebanon
- Posts
- 413
no I think he's concatenating all in body
-
03-14-2008, 03:16 PM #10Junior Guru Wannabe
- Join Date
- Feb 2007
- Posts
- 40
It seems like your mail server is not working. Have you checked that already?
-
03-14-2008, 03:53 PM #11Disabled
- Join Date
- Oct 2005
- Location
- Six Degrees From You
- Posts
- 1,079
Have you turned error reporting on? If so what does it say?
Paul
-
03-23-2008, 11:42 PM #12Temporarily Suspended
- Join Date
- Sep 2004
- Location
- US
- Posts
- 29
You will receive the email ONLY when this IF condition is met. Try inserting an
echo "anything";
before the mail function. If the text is displayed means something is wrong with the email delivery OTHERWISE it would mean the IF condition is not TRUE.