Closed bob85 closed 10 years ago
Hey Bob,
I am curious as to what version of PHP you are using. sendmail.php uses the json_encode function to generate the response, which was added in version 5.2. If you are using an early version, it probably will not generate the response (and hence the timeout). You can either upgrade your PHP version or there are other solutions: http://stackoverflow.com/questions/2370968/how-can-i-decode-json-in-php-5-1
Let me know how things work out.
Jon
Hi Jon,
According to output, server is on: PHP Version 5.5.9-1ubuntu4
I will ask my son to assist with suggested repair.
Thanks, Bob
On 6/20/2014 5:49 PM, Jon Bake wrote:
Hey Bob,
I am curious as to what version of PHP you are using. sendmail.php uses the json_encode function to generate the response, which was added in version 5.2. If you are using an early version, it probably will not generate the response (and hence the timeout). You can either upgrade your PHP version or there are other solutions: http://stackoverflow.com/questions/2370968/how-can-i-decode-json-in-php-5-1
Let me know how things work out.
Jon
— Reply to this email directly or view it on GitHub https://github.com/jonmbake/bootstrap3-contact-form/issues/3#issuecomment-46730433.
Hi Bob.
I am pretty sure the problem stems from the call to PHP's mail function (line 59 of sendmail.php) taking a long time to finish on your server. The sendmail script waits for the function to return with a success and then it responds with the message 'Your message was successfully submitted.'. Your connection is timing out before the success response is sent back. I found this on stackoverflow: http://stackoverflow.com/questions/7578952/sending-mail-takes-long-time-in-localhost
You can do 2 things:
//try to send the message
if(mail(MY_EMAIL, EMAIL_SUBJECT, setMessageBody($fields_req), "From: $email")) {
echo json_encode(array('message' => 'Your message was successfully submitted.'));
} else {
header('HTTP/1.1 500 Internal Server Error');
echo json_encode(array('message' => 'Unexpected error while attempting to send e-mail.'));
}
to:
//try to send the message
mail(MY_EMAIL, EMAIL_SUBJECT, setMessageBody($fields_req), "From: $email");
echo json_encode(array('message' => 'Your message was successfully submitted.'));
Unfortunately, the second version will not alert the user if there was an error while attempting to send their email.
Hope this helps!
Jon
Jon, Thanks for your efforts. I'm a real beginner so js is a mystery.
The form is working sort of: I receive test emails sent from the form but the contact form page never finishes sending. Console info: Firefox console: SyntaxError: Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery.min.js:1 Error: http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js is being assigned a //# sourceMappingURL, but already has one Use of getPreventDefault() is deprecated. Use defaultPrevented instead. jquery.min.js:5 TypeError: response.responseJSON is undefined contact-form.js:46
Chrome: Failed to load resource: the server responded with a status of 504 (Gateway Time-out) http://partnersinbpc.com/library/sendmail.php Uncaught TypeError: Cannot read property 'message' of undefined contact-form.js:46
Any suggestions appreciated!