Server Connection Has Reset - Why?

Hi all,

Please see this site:

For some reason it keeps saying that the server has timed out. I don’t fully understand it because it works on my test site

It’s nothing particularly complicated, just a very small php file that sends an email when the form has been filled in. I really can’t understand why on earth it works fine on one and not on the other.

Any help is much appreciated.

Also… I know it’s the wrong forum, and probably not such a pressing issue… but if anyone knows why it is so difficult to click on the “no” part of the form I’d appreciate some knowledge on that too. It seems quite a usability problem that it’s so difficult to click on it. It just seems to prefer “yes” to “no”. My form is a yes man.

What error messages are being displayed or are being put into your error logs?

It’s a clients site, so I don’t currently have access to the error logs, I can always ask for access.

The error message is:

The connection was reset
The connection to the server was reset while the page was loading.
The site could be temporarily unavailable or too busy. Try again in a few
If you are unable to load any pages, check your computer’s network
If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.

Other pages for the site work. Indeed the page prior to sending the script works. The script is tiny, it shouldn’t be timing out or anything like that. I shall go back and double check the script, perhaps there is some error there.

Compare the output of phpinfo() on both machines.

Ask for confirmation that the mail() function has not been disabled.

Sorry, cannot think of anything else - otherwise you will have to post some code I think.

Thanks I’ll see the phpinfo thing first. I am completely noob, but at least I can hopefully spot some differences at the very least!

It already has a mail script on the current site so I think that is not the problem most likely.

I particularly dislike this hosting set up, although perhaps it’s more to do with what I’m used to!

I have checked the PHPinfo and everything seems ok to my noob eye. Both seem to have the mail settings turned on etc. In fact my contact form does indeed send me a contact form, it just appears like it won’t, so god knows how long it actually takes. It also arrives from some funny address - the web hosts.

I just can’t get my head around what would cause this issue, it works on my local machine with XAMPP, and also on my test server, just not on the client machine. I also managed to receive a blank contact form randomly too, which I didn’t do, so I’m not quite sure how that’s worked either.

As a further update… When I send from IE and Firefox it seems to be different servers that send the emails. I have so far received the email from 3 servers (I assume). - which had the correctly formatted email title etc. - which did not have the email from name but instead $ - which had the same as above with a differing part after @

Can anyone clear up as to why there would be three different servers? Firstly, 26 is the one sent from IE. The other two are both Firefox, yet have different results. The fact that $EmailFrom is appearing instead of the email address is quite strange, and might hold the key. Can anyone assist?

The fact that $EmailFrom is appearing instead of the email address is quite strange, and might hold the key.

Probably best to show us the code leading up to the mail() being sent, where the var $EmailFrom is being invoked.

$Message = 'This is a message sent by the My Page';
$EmailFrom = 'My Website';
$EmailTo = '';
$Subject = 'Message from MySite';
$Company = Trim(htmlentities($_POST['company']));
$Employees = Trim(htmlentities($_POST['employees']));
$Scheme = Trim(htmlentities($_POST['scheme'])); 
$Phone = Trim(htmlentities($_POST['phone'])); 
$Email = Trim(htmlentities($_POST['email'])); 
$Forename = Trim(htmlentities($_POST['forename']));
$Surname = Trim(htmlentities($_POST['surname']));

if (isset($_POST['provider'])) {
    $Provider = 'The person does not have a provider';
	else {$Provider = Trim(htmlentities($_POST['provider']));}

// prepare email body text
$Body = '';
$Body .= 'Forename:     ';
$Body .= $Forename;
$Body .= '\
$Body .= 'Surname:     ';
$Body .= $Surname;
$Body .= '\
$Body .= 'Tel:     ';
$Body .= $Phone;
$Body .= '\
$Body .= 'Email:     ';
$Body .= $Email;
$Body .= '\
$Body .= 'Do they Currently Have a scheme?    ';
$Body .= $Scheme;
$Body .= '\
$Body .= 'Who is their current provider     ';
$Body .= $Provider;
$Body .= '\
$Body .= 'How many employees do they have?     ';
$Body .= $Employees;
$Body .= '\
$Body .= 'Company Name     ';
$Body .= $Company;
$Body .= '\

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

// redirect to success page 
if ($success){
  print '<meta http-equiv=\\"refresh\\" content=\\"0;URL=\\">';
  print '<meta http-equiv=\\"refresh\\" content=\\"0;URL=\\">';

Any ideas you have would be excellent :slight_smile:

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

$EmailFrom needs to be enclosed in double quotes, the way you have done it will just print the word EmailFrom not the variable content.

if ($success){
print ‘<meta http-equiv=\“refresh\” content=\“0;URL=\\”>’;
print ‘<meta http-equiv=\“refresh\” content=\“0;URL=\\”>’;

why not just use a header() redirect?

I guess I changed it at some point trying to find a solution.

Have implemented your header redirect suggestion too (any particular reason to choose one solution over another?)

It still doesn’t work on the live site. It seems to get stuck as soon as I press submit and just says waiting with the loading sign :frowning: I’m at a loss as to why that file would take so long to load for any reason. It never reaches the next page, but the emails do eventually arrive.

ive filled in the forum and get sent to emailer.php where it just seems to load on a loop. No errors popup. it does eventually bring up the mentioned error page after about 5 minutes. Your best bet is to get hold of the error logs. I dont see any immediate php errors so it may be something to do with the server setup. I didnt get the email however.

lol you probably will do in a little while. You’ll receive it from the server as you have correctly pointed out I haven’t set it up properly to deal with the actual from name.

I’ll see if I can get the server logs.