PHP email form not working for some reason

Alex

New Member
I am using WAMP and everything works fine on it (including other PHP files). When I fill out the form properly, I do get redirected to the right page, which says:
"Your message was sent
Your message was successfully sent! Thank you for contacting us, we will reply to your inquiry as soon as possible!"

However, for some reason, I am not receiving an email after completing the form.

Here are the files I'm using:
contact.htm: http://pastebin.com/nE18nkWZ
contact.php: http://pastebin.com/yQv6uHWy
thanks.htm: http://pastebin.com/L2Ln3fB8b


The exact same problem occurs with this set of files:
contactform.htm: http://pastebin.com/ED4eqCZ9
send_form_email.php: http://pastebin.com/m6T5LKtv

I did fill out my email properly in the PHP files.

Thanks a lot for any help
 

DHDdirect

New Member
You can put this in your code to show if there are any PHP errors:

Code:
[FONT=Consolas][COLOR=#ff8000]// Report all PHP errors[/COLOR][/FONT]
[FONT=Consolas][COLOR=#0000bb]error_reporting[/COLOR][COLOR=#007700](-[/COLOR][COLOR=#0000bb]1[/COLOR][/FONT][COLOR=#007700][FONT=Consolas]);[/FONT][/COLOR]
That should hopefully lead you in the right directly of why it's failing.



Then you can put in a redirect for a faulted attempted. Such as:

Code:
[COLOR=#007700]if(mail($myemail, $subject, $message)) {[/COLOR]
[COLOR=#007700]/* Redirect visitor to the thank you page */[/COLOR]
[COLOR=#007700]header('Location: thanks.htm');[/COLOR]
[COLOR=#007700]exit();[/COLOR]
[COLOR=#007700]} else {[/COLOR]
[COLOR=#007700]/* Redirect visitor to the error page */[/COLOR]
[COLOR=#007700][COLOR=#007700]header('Location: failed.htm');[/COLOR]
[COLOR=#007700]exit();[/COLOR]
[COLOR=#007700]}[/COLOR]
[/COLOR]

But if you are testing this on your local computer it may be failing because there isn't a mail server setup on your local machine for the mail() command to use. You can Google "PHP sendmail_from" and you should find ways to setup SMTP info in PHP.ini.

Hope that helps.
 
Last edited:

Alex

New Member
Well turns out it does work on my website.. Thanks so much. and I'll remember the error reporting code too
 
Top