Jump to content

Contact Form Suddenly Stopped Working


Recommended Posts



I've been using the same contact form for over a year for several websites. I've successfully been able to tweak it to suit my needs for each project. However, I am currently trying to use it again, and the form appears to submit, but the email never shows up. I've tried it with two different emails. 


I tested the form on a previous site I designed, and it no longer works either. I can't test all the others because I no longer can access those clients' emails, but they are on the same server.


I'm more of a designer than programmer & know enough PHP to be "dangerous", aka tweak existing code to make it do what I need. I used a verifier & it told  me my php was fine & dandy. I'm not sure where the error lies...


Thanks for any insight!


This is my form in the HTML page:

<form name="contactformlite" method="post" action="lite_process.php" onSubmit="return validate.check(this)" target="_self">
      <table class="cflite">
      <tr><td><h3>FREE Gas Card Entry Form</h3></td></tr>

	  <td class="cflite_td">
      <label for="Full_Name" class="required">
      Full Name<span class="required_star"> * </span></label>
	  <input type="text" name="Full_Name" id="Full_Name" maxlength="100" style="width:72%; display:block; margin-right:0px; float:right;">
	 <td valign="top" class="cflite_td">
	  <label for="Email_Address" class="not-required">Email Address<span class="required_star"> * </span></label>
	  <input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:72%; display:block; margin-right:0px; float:right;">
	 <td valign="top" class="cflite_td">
	  <label for="Telephone_Number" class="required">Phone Number<span class="required_star"> * </span></label>
	  <input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:72%; display:block; margin-right:0px; float:right;">
	 <td valign="top" class="cflite_checkbox">
     	  <input type="checkbox"  name="Prop_Mgr" id="Prop_Mgr" value="y">
<input type="hidden" name="Prop_Mgr" value="n" />
	  <label for="Prop_Mgr" class="not_required" style="margin:0px;">I am a retail property manager.</label>
<input type="checkbox"  name="Contact_Request" id="Contact_Request" value="y">
<input type="hidden" name="Contact_Request" value="n" />
	  <label for="Contact_Request" class="not_required" style="margin:0px;">I would like more information on TWS' services.</label>
<input type="checkbox"  name="Permission" id="Permission" value="y">
<input type="hidden" name="Contact_Request" value="n" />
	  <label for="Permission" class="required" style="margin:0px;"><span class="required_star"> * </span>I am a new facebook fan of TWS as of 2/25/14. I understand that this entry also signs me up for the monthly email newsletter, which I can unsubscribe from at any time. I agree to be contacted by TWS with the phone number or email address provided here.</label>
      <td class="allfields"><span class="required_star"> * </span>Required for Entry.</td></tr>
    <td class="cflite_bottom">         	  
      <input type="submit" value="Enter Me Now!" id=submit></td>

This is my first php file:


if(isset($_POST['Email_Address'])) {
	include 'lite_settings.php';
	if($email_to == "youremailaddress@yourdomain.com") {
		die("This message is for the Webmaster. Please enter your email address into the file 'lite_settings.php'");
	function died($error) {
		echo "Sorry, but there were error(s) found with the form you submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please close this window and fix these errors.<br /><br />";
	if(!isset($_POST['Full_Name']) ||
		!isset($_POST['Email_Address']) ||
		!isset($_POST['Telephone_Number']) ||
		!isset($_POST['Prop_Mgr']) ||
		!isset($_POST['Contact_Request']) ||
		!isset($_POST['Permission'])) {
		died('We are sorry, but there appears to be a problem with the form you submitted.');		
	$full_name = $_POST['Full_Name']; // required
	$email_from = $_POST['Email_Address']; // required
	$telephone = $_POST['Telephone_Number']; // required
	$prop_mgr = $_POST['Prop_Mgr']; // not required
	$contact_request = $_POST['Contact_Request']; // required
	$permission = $_POST['Permission']; // required
	$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
  	$error_message .= 'The email address you entered does not appear to be valid.<br />';
  if(strlen($full_name) < 2) {
  	$error_message .= 'Your name does not appear to be valid.<br />';

if(strlen($telephone) < 12) {
  	$error_message .= 'Your phone number does not appear to be valid. Use format 000-000-0000<br />';
  if(strlen($error_message) > 0) {
	$email_message = "Form details below.\r\n";
	function clean_string($string) {
	  $bad = array("content-type","bcc:","to:","cc:","href");
	  return str_replace($bad,"",$string);
	$email_message .= "Full Name: ".clean_string($full_name)."\r\n";
	$email_message .= "Email: ".clean_string($email_from)."\r\n";
	$email_message .= "Telephone: ".clean_string($telephone)."\r\n";
	$email_message .= "Prop_Mgr: ".clean_string($prop_mgr)."\r\n";
	$email_message .= "Contact_Request: ".clean_string($contact_request)."\r\n";
	$email_message .= "Permission: ".clean_string($permission)."\r\n";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
<script>location.replace('<?php echo $thankyou;?>')</script>

And the second "settings" file (I put in a fake email & site here, for privacy purposes):


$email_to = "fakename@email.com"; // your email address
$email_subject = "Facebook Gas Contest Entry"; // email subject line
$thankyou = "http://fakesite.com"; // thank you page


Lastly, here is my javascript:

function has_id(id){try{var tmp=document.getElementById(id).value;}catch(e){return false;}
return true;}
function has_name(nm){try{var tmp=cfrm.nm.type;}catch(e){return false;}
return true;}
function $$(id){if(!has_id(id)&&!has_name(id)){alert("Field "+id+" does not exist!\n Form validation configuration error.");return false;}
if(has_id(id)){return document.getElementById(id).value;}else{return;}}
function $val(id){return document.getElementById(id);}
function trim(id){$val(id).value=$val(id).value.replace(/^\s+/,'').replace(/\s+$/,'');}
var required={field:[],add:function(name,type,mess){this.field[this.field.length]=[name,type,mess];},out:function(){return this.field;},clear:function(){this.field=[];}};var validate={check:function(cform){var error_message='Please fix the following errors:\n\n';var mess_part='';var to_focus='';var tmp=true;for(var i=0;i<required.field.length;i++){if(this.checkit(required.field[i][0],required.field[i][1],cform)){}else{error_message=error_message+required.field[i][2]+'  is invalid\n';if(has_id(required.field[i][0])&&to_focus.length===0){to_focus=required.field[i][0];}
return tmp;},checkit:function(cvalue,ctype,cform){if(ctype=="NOT_EMPTY"){if(this.trim($$(cvalue)).length<1){return false;}else{return true;}}else if(ctype=="EMAIL"){exp=/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if($$(cvalue).match(exp)==null){return false;}else{return true;}}},trim:function(s){if(s.length>0){return s.replace(/^\s+/,'').replace(/\s+$/,'');}else{return s;}}};
Link to comment
Share on other sites

The code wouldn't randomly stop working if nothing changed. If you are absolutely certain that you made no changes to any of your files, then contact your host and take it up with them. They must have made changes on the server that has affected your code. It could be any number of things like upgrading or changing their email server and improperly configuring it or updating php config file accordingly. They could have upgraded php and maybe something in your code no longer works. Or a million other things.

Link to comment
Share on other sites

one thing you can check is


step 1) turn on error reporting. Put this at the top of the file that makes the mail() call:


step 2) remove the error suppression from your mail call (remove the @)


mail($email_to, $email_subject, $email_message, $headers);
step 3) comment out the redirect stuff


//header("Location: $thankyou");
<script>//location.replace('<?php echo $thankyou;?>')</script>
Now go through your form process and see if any errors are output. This may or may not produce something that will give you a clue.
Link to comment
Share on other sites

I got a notice from the server a month or so ago saying they upgraded the php to 5.4 from 5.2. But I tested a form then & it worked at the time...


I have edited the PHP code above, so there may be an error in it that the others did not have.  The others have not beed touched since they were last working. I will contact that server about those ones - thanks.


IDK about the server for this one, because I just have FTP access. I don't even know what server they have :X. If the PHP looks okay, then I'll contact their web designer. I'm just kinda in a crunch & was actually HOPING it was a dumb error on my part.


EDIT - I'll give the above a shot as well, thanks.

Edited by iheartart
Link to comment
Share on other sites

Okay this is the error:

Warning: mail() [function.mail]: SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server. in d:\web\twsfs.com\wwwroot\contest\lite_process.php on line73



Server issue then...?

Link to comment
Share on other sites

well, wait a minute.. what are you attempting to use in $email_from? It sounds like you are attempting to use a "From: " email address that doesn't match your server/domain and the email server settings are (rightfully) setup to not allow that. It is unlikely that your host will change the email server config to allow this. In fact, if you are using From: email addresses that don't match, there's a very good chance your host changed the email config because of you, and frankly I'm surprised you have not received notification about it. But if you are indeed using a "From: " email address that matches your domain, then yeah, contact your host.

Link to comment
Share on other sites

In addition what .josh said, also check into php.ini file whether you're able to use open php short tags for that php's version, or just  change /* line 73 */  from <? to <?php


PS: I also see prospective depricated php functions in your script in case you want to use php 5.4+ version, you need to replace them. 

Edited by jazzman1
Link to comment
Share on other sites

If I'm understanding this, the $email_from seems to be the email address the user fills in on the form (?). So no, it wouldn't be my server or domain. For some reason I thought the php sent the form to the email through the server, not from another email (?). The email it's being sent to in this case is a gmail; not the same server/domain either. The other forms that stopped working went to emails with the same domain though.


I thought it was an SMTP authentication issue at first....that all of sudden they may require it.

Link to comment
Share on other sites

"To find" is not the right expression when we're tallking about a programming! You need to re-write the scripts yourself understanding 100% of every single tag of your code or just to hire some programmer knowing enough programming to do this job for you.

Edited by jazzman1
Link to comment
Share on other sites

well there's certainly outdated code in there but the problem is definitely the mail call. No, it does not send an email from the actual email account. So if you were to put "iheartart@phpreaks.com" into your "From: " field in your form, your server isn't going to log on to our server and send it from that email address. Your server is going to send it from itself, because it's the email server. And it has your own domain(s) tied to it, just like our email server has phpfreaks.com domain tied to it.


So therein lies the problem. Your email server, which is located on yoursite.com, is trying to send an email claiming its from somewhereelse.com. You can make an email claim it's from anywhere or anybody. That's easy. That's exactly what your script does. The problem with that is whether or not your email server will allow you to do it (which according to the error message, it won't), or whether the recipient server will outright deny it, or accept it but mark as spam or legit.


For example, if you try to send an email from yoursite.com to a someone@gmail.com, but claim it's from you@someothersite.com instead of you@yoursite.com.. well gmail sees that your email server that is located on yoursite.com is trying to send an email claiming it's coming from someothersite.com. Now, gmail may decide to put it into someone@gmail.com's mailbox nonetheless. It boils down to whether or not it decides the email is spam.


But claiming an email is from a domain that doesn't match the domain the email really came from is a really good way to get on a spam list and get your email server blacklisted. This is something that hosts generally want to avoid, especially hosts running shared servers. Think about it. If someone else is using the same host as you and you're both on the same shared server, that means you're also sharing email servers.


Now lets say that asshole starts sending emails out, spoofing who they are from. This doesn't just get yoursite.com's domain put on spam blacklists. This usually also gets the host's email server put on the black list, and any other domains that email sent emails for. That means if some asshole sharing the same shared host as you starts a spam operation and your host lets it through, it may result in your site's emails being blacklisted as spam. You don't want some other random asshole customer doing this and affecting your site, do you? No. And neither does your host, because then people stop hosting their sites with them. Which is why hosts will usually always put settings on their mail server to reject attempts to send emails out that don't match the domain of your site.


This is probably why your scripts suddenly stopped working. In the past, your host didn't have the email server setup to reject this. But they more than likely got flagged as a spam server, and so they put the measure in place to prevent it. So, I was not joking when I said earlier that it could have been because of your site having a script on it that allows for people to invoke mail calls claiming to be from a domain other than your site. Maybe not directly your site.. depends on how much traffic and emails you are getting. More likely scenario is some spam operation came upon your site and figured out through your scripts that the host didn't check for that shit and then they signed up for a hosting plan and went to town.


Now, it seems to me from looking at your script, that the intention of your script is to have someone fill out a form that provides contact info and interest(s) or whatever, and then that email gets sent to you, as a lead or whatever. And this script is using the email address the person puts into the form as the "From: " address, for no good reason. There's literally no good reason for this, and every bad reason in the world for this.


Obviously you want to know the visitor's email address, but it should be included as info in your email body (which it already is), but not as the person the email is coming from. Just hardcode the "From: " header to your site's main email address. Or just remove the "From: " header altogether and let the mail server use its own default, and your problem should be solved.


But I'd look to update this script or find an updated one or hire someone to update it or w/e on top of that, regardless, because it is outdated, full of deprecated stuff. And honestly, if your host has gone this long and has only just not gotten around to disallowing it.. you should probably think about switching hosts; something like this is like.. Shared Hosting 101, so only God knows what other kinds of bad config and practices may be going on behind the curtains.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.