Jump to content

Contact.php Email Form Not Emailing


bigjohnsta

Recommended Posts

I posted this same topic on another PHP forum here: http://forums.x10hosting.com/off-topic/97518-contact-php-email-form-not-emailing.html

 

But I haven't had any luck with fixing my problem yet. PLEASE HELP!

 

Here is my index.htm and contact.php files:

 

INDEX.HTM:

 

<form method="POST" action="contact.php">

<table width="677" height="172" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td width="244" height="10">

<p class="style12">Email From:<span class="style4 style19">*</span><br>

<input type="text" name="EmailFrom">

 

</td>

<td width="369"><p class="style12 style1">Company:<br>

<input type="text" name="Company"></td>

</tr>

<tr>

<td height="10"><p class="style12">Subject: <br>

<input type="text" name="Subject"></td>

<td height="10"><p class="style12 style1">Website:<br>

<input type="text" name="Website"></td>

</tr>

<tr>

<td height="99"><p class="style12 style1">Name:<br>

<input type="text" name="Name">

<table width="244" height="80" border="0" cellpadding="0" cellspacing="0">

<tr>

<td> </td>

</tr>

</table>

</td>

<td><p class="style12 style1">Message:<br>

<textarea name="Message" cols="50"></textarea>

<p><span class="style12 style1">

<input type="submit" name="submit" value="Send Message">

</span>

<span class="style12 style1 style2 style13">Fields marked <span class="style18">(*)</span> are required</span></td>

</tr>

</table></form>

 

 

CONTACT.PHP:

 

<?php

// Website Contact Form Generator

// http://www.tele-pro.co.uk/scripts/contact_form/

// This script is free to use as long as you

// retain the credit link

 

// get posted data into local variables

$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));

$EmailTo = "[email protected]";

$Subject = Trim(stripslashes($_POST['Subject']));

$Name = Trim(stripslashes($_POST['Name']));

$Company = Trim(stripslashes($_POST['Company']));

$Website = Trim(stripslashes($_POST['Website']));

$Message = Trim(stripslashes($_POST['Message']));

 

// validation

$validationOK=true;

if (Trim($EmailFrom)=="") $validationOK=false;

if (!$validationOK) {

print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

exit;

}

 

// prepare email body text

$Body = "";

$Body .= "Name: ";

$Body .= $Name;

$Body .= "\n";

$Body .= "Company: ";

$Body .= $Company;

$Body .= "\n";

$Body .= "Website: ";

$Body .= $Website;

$Body .= "\n";

$Body .= "Message: ";

$Body .= $Message;

$Body .= "\n";

 

// send email

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

 

// redirect to success page

if ($success){

print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";

}

else{

print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/157772-contactphp-email-form-not-emailing/
Share on other sites

Wow, you couldn't wait 2 days before jumping elsewhere to post this. Such urgency.... I'm not going to read all the posts in your other topic, so please address the following.

 

1. Describe the problem - what's not working? Any errors? What is it not doing that it's supposed to do?

2. Use


tags.

There's only like 3 replies to my other thread....

 

And the problem is exactly what you read. The email doesn't send, and there is the code right there.

 

Simple as that.

 

INDEX.HTM FILE:

 

<form method="POST" action="contact.php">
<table width="677" height="172" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="244" height="10">
<p class="style12">Email From:<span class="style4 style19">*</span><br>
<input type="text" name="EmailFrom">

</td>
<td width="369"><p class="style12 style1">Company:<br>
<input type="text" name="Company"></td>
</tr>
<tr>
<td height="10"><p class="style12">Subject: <br>
<input type="text" name="Subject"></td>
<td height="10"><p class="style12 style1">Website:<br>
<input type="text" name="Website"></td>
</tr>
<tr>
<td height="99"><p class="style12 style1">Name:<br>
<input type="text" name="Name">
<table width="244" height="80" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
</td>
<td><p class="style12 style1">Message:<br>
<textarea name="Message" cols="50"></textarea>
<p><span class="style12 style1">
<input type="submit" name="submit" value="Send Message">
</span>
<span class="style12 style1 style2 style13">Fields marked <span class="style18">(*)</span> are required</span></td>
</tr>
</table></form>

 

 

CONTACT.PHP FILE:

 

<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "[email protected]";
$Subject = Trim(stripslashes($_POST['Subject']));
$Name = Trim(stripslashes($_POST['Name']));
$Company = Trim(stripslashes($_POST['Company']));
$Website = Trim(stripslashes($_POST['Website']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Website: ";
$Body .= $Website;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

I figured out that Comcast does not allow incoming PHP email messages. So if you're using a comcast email as an incoming email address to receive these PHP messages, it does not work. I signed up for a Gmail account and it works just fine.

 

Thanks anyway!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.