iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-09-2006, 02:55 PM
WebProWorld Pro
 
Join Date: Jul 2004
Location: Irvine, CA
Posts: 125
spenland RepRank 0
Default Can't get php forms to send email on new server

Hi guys, I just signed up with a new dedicated server and have been testing a few things. Everything works great except for my email forms. Now the site is still just an ip address at this point with no domain name associated to it, would this cause an email not to be sent?

Basically I have a form that POST's to the page form_process.php that I have included below...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="language" content="en-us">
<title></title>
<link href="css/fonts.css" rel="stylesheet" type="text/css">
<link href="css/tabs.css" rel="stylesheet" type="text/css">
<link href="css/menu.css" rel="stylesheet" type="text/css">

<script language="javascript" src="js/google.js"></script>

</head>

<?
//require_once("db.php");
//session_start();


// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$title = $_POST['title'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$address = $_POST['address'];
$address1 = $_POST['address1'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$companydo =$_POST['companydo'];
$productsinterest =$_POST['productsinterest'];
$application =$_POST['application'];
$questions =$_POST['questions'];
$referredfrom =$_POST['referredfrom'];
$request1 =$_POST['request1'];
$request2 =$_POST['request2'];
$request3 =$_POST['request3'];
$specify =$_POST['specify'];


/* Let's strip some slashes in case the user entered
any escaped characters. */

$email = stripslashes($email);
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$address = stripslashes($address);
$address1 = stripslashes($address1);
$city = stripslashes($city);
$zip = stripslashes($zip);
$phone = stripslashes($phone);
$fax = stripslashes($fax);

/* Lets clean up the phone number fields */

$phone = ereg_replace("[)(.-]","",$phone);
$fax = ereg_replace("[)(.-]","",$fax);

/* Do some error checking on the form posted fields */

if((!$request1) && (!$request2) && (!$request3) || (!$first_name) || (!$last_name) || (!$title) || (!$company) || (!$phone) || (!$email) || (!$address) || (!$city) || (!$state) || (!$zip) || (!$country) || (!$referredfrom) || (!$specify)){

?>
<table width="900" border="0" cellpadding="0" cellspacing="0" align="center">

<tr>
<td height="88" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php include('header.php'); ?>
</table> </td>
</tr>
<tr>
<td width="158" height="956" valign="top" class="border_right"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"></td></tr>
<tr>
<td valign="top"><?php include('sideleft.php'); ?></td></tr>
</table></td>
<td width="742" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<?
echo '
';
echo '
';
echo "<SPAN class='content'>";
echo "<center />";
echo '<font color="#FF0000"> You did not submit the following required information!</font>

';
if(!$request1 && !$request2 && !$request3){
echo "Choose one or more of the following: Product Information,
a Product Catalog or Sign Up for our Newsletter.
Please click the BACK button.

";
}
if(!$first_name){
echo "Your First Name is a required field. Please click the BACK button.
";
}
if(!$last_name){
echo "Your Last Name is a required field. Please click the BACK button.
";
}
if(!$title){
echo "Your Job Title is a required field. Please click the BACK button.
";
}
if(!$company){
echo "Your Company Name is a required field. Please click the BACK button.
";
}
if(!$phone){
echo "Phone Number is a required field. Please click the BACK button.
";
}
if(!$email){
echo "Email Address is a required field.Please click the BACK button.
";
}
if(!$address){
echo "Address is a required field. Please click the BACK button.
";
}
if(!$city){
echo "City is a required field. Please click the BACK button.
";
}
if(!$state){
echo "State is a required field. Please click the BACK button.
";
}
if(!$zip){
echo "Zip Code is a required field. Please click the BACK button.
";
}
if(!$country){
echo "Country is a required field. Please click the BACK button.
";
}
if(!$referredfrom){
echo "How did you hear about Omnitron is a required field. Please click the BACK button.
";
}
if(!$specify){
echo "Please Specify where heard about Omnitron is a required field. Please click the BACK button.
";
}
echo '</span>';
echo '<tr /><td width="846" height="624"></td></tr></table></td></tr>';
echo '<tr /><td height="90" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">';
include('footer.php');
echo '</table></td></tr></table>';


/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
};


$toaddress = "me@mydomain.com";
// Let's mail the user!
$subject = "A Web Site Visitor has Requested the following: $request1 $request2 $request3";
$message = "

A web site visitor has requested the following: $request1 $request2 $request3

First Name: $first_name
Last Name: $last_name
Company: $company
Title: $title
Address: $address
Address Cont.: $address1
City: $city
State: $state
Zip: $zip
Country: $country
Phone: $phone
Fax Phone: $fax
Email: $email

What does your company do?
$companydo

What products are you interested in?
$productsinterest

What is your application?
What type of network do you have?
$application

If you have any question for our product specialists,
please enter in the space below:
$questions

Heard of us from - $referredfrom

Specifics: $specify

This is an inter office email only, please do not reply! ";

mail($toaddress, $subject, $message, "From: My Company Request<marketing@mydomain.com>");
?>
<table width="900" border="0" cellpadding="0" cellspacing="0" align="center">

<tr>
<td height="88" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php include('header.php'); ?>
</table> </td>
</tr>
<tr>
<td width="158" height="956" valign="top" class="border_right"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"></td></tr>
<tr>
<td valign="top"><?php include('sideleft.php'); ?></td></tr>
</table></td>
<td width="742" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<?
echo '
';
echo '
';
echo "<SPAN class='content'>";
echo "<center />";
echo 'Thank you for filling out our form.';
echo '
';
echo '

<a href=index.php>Return To Homepage</a>';
echo '
';
echo '<center><hr width="500" /></center>';
echo '</span>';

echo '<tr /><td width="846" height="624"></td></tr></table></td></tr>';
echo '<tr /><td height="90" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">';
include('footer.php');
echo '</table></td></tr></table>';

// Result Page to let User Know that they've been accepted in to the site

?>

Obviously I've replaced my real email address above , but you get the idea. So anyway this script seems to work OK for error checking, and when all the fields on the form are filled I get a nice "your email has been sent" message. But I never receive the email!

My old server is IIS and my new one is Linux, so I'm not sure if there is some sort of configuration that I'm missing.

Any ideas?
Reply With Quote
  #2 (permalink)  
Old 03-13-2006, 06:03 PM
WebProWorld Pro
 
Join Date: May 2004
Location: Austin, TX
Posts: 199
steve0 RepRank 0
Default

Did you can check the (apache) error_log or maillog for any hints?

This may sound strange.. but try putting the "From" information into a variable as well.

The format I use is something like:
$mailer = mail($to, $subject, $message, $headers);
__________________
Hardcore Programming Solutions and Coffee Drinker
Reply With Quote
  #3 (permalink)  
Old 03-14-2006, 02:01 AM
southplatte's Avatar
WebProWorld Veteran
 
Join Date: Jul 2003
Location: Colorado
Posts: 358
southplatte RepRank 1
Default

Since this is on a dedicated server box, you may want to check the php.ini file to verify that path to sendmail is setup properly.
Reply With Quote
  #4 (permalink)  
Old 03-14-2006, 07:10 PM
WebProWorld Pro
 
Join Date: Jul 2004
Location: Irvine, CA
Posts: 125
spenland RepRank 0
Default

thanks for the response guys. I have a Plesk control panel on my dedicated server so I'm not really sure how to check error logs or how to find the .ini file you spoke of. How would I go about doing this?
Reply With Quote
  #5 (permalink)  
Old 03-14-2006, 08:38 PM
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 1,782
cyanide RepRank 0
Default

You will need to log into shell in order to see php.ini and other config files.
Also, php tends to send out mail as "nobody", so if you have it blocked or turned off, it won't send either
__________________
|
Web Hosting Guru
| Need Help For Your Forum?
Reply With Quote
  #6 (permalink)  
Old 03-14-2006, 08:59 PM
DrTandem1's Avatar
WebProWorld 1,000+ Club
 
Join Date: Oct 2003
Location: Encinitas, CA
Posts: 1,830
DrTandem1 RepRank 2
Default

If the script is trying to send to the same email address that is being used as a forwarding address, it could cause a conflict with the new host you are using.

Have the script send to a completely separate email address, such as a hotmail account or something. From what you say, it appears the script is running fine and is the same script you used successfully on a different host. So, I think a conflict in the email of the new host is causing the problem, not the script.

For instance, on the script you have posted you have set the "toaddress" variable as "me@mydomain.com." I am assuming that this is fictitious just for your question on this forum. Change it to some other email address outside of your host and your own ISP email for testing purposes.
__________________
DrTandem's San Diego Web Page Design, drtandem.com
Reply With Quote
  #7 (permalink)  
Old 03-14-2006, 09:04 PM
WebProWorld Pro
 
Join Date: Jul 2004
Location: Irvine, CA
Posts: 125
spenland RepRank 0
Default

Well apparently the "Sendmail" module on the server was configured incorrectly as "localhost" instead of pointing to the correct IP address. Thanks for the help guys!
Reply With Quote
  #8 (permalink)  
Old 03-15-2006, 05:08 AM
WebProWorld Pro
 
Join Date: Mar 2004
Location: Bonnie Scotland
Posts: 103
colr RepRank 0
Default

If the server is 'just an IP address' at the moment, then I assume you haven't yet setup any domains on it.

Your mailserver *should* have been setup by your ISP to not be an open relay. This is accomplished by only accepting SMTP email addressed to domains that exist on the server. i.e. it wont accept smtp emails that are addressed to recipients who dont exist on your server.

Since you have no domains on the server at the moment, all email you try to send through your SMTP server will be viewed as a relay attempt, and subsequently dropped.

The easiest and quickest way to test this is to telnet into the server at port 25 and try and send a mail manually. Any relay attempts should be reported as such.

colr__
__________________
Colin Reid
East Kilbride
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:01 AM.



Search Engine Optimization by vBSEO 3.3.0