Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Lea Marolt
5,127 PointsContact form not quite working right
Right, so I've recently deployed my own website, and I was pretty diligent at following the tutorial on setting a contact form... but I've tried it, and it doesn't seem to be working. As in, I haven't received any emails in the address I've specified. And no, I'm not thinking people will immediately start contacting me through that form, I sent some myself to check it (:
Thanks
4 Answers
Ross Mackay
5,859 PointsHave you got a link to the website? I haven't done that course but remember that if it's a php form you'll need php running on the server.
It may sound obvious but have you checked your spam too?
Patrick Devins
8,515 PointsAre you using a contact form pluggin or did you write the contact form yourself? Are you using a PHP framework (CodeIgniter, Cake, Laravel) or are you using WordPress?
Whenever I have run into this problem it has been because the server's SMTP host and port weren't set up correctly either through the pluggin I was using or through the PHP framework's Email Helper Class. All the code for the website looks fine, and PHP is definitely installed (if it weren't I don't think your page would even render, since part of PHP is a script compiler that outputs HTML and without it, some/most/all of your HTML wouldn't be there).
Lea Marolt
5,127 PointsI'm not using Wordpress. Embarrassingly enough, I'm not sure I'm using a framework, because I pretty much followed the treehouse tutorial about this. - http://teamtreehouse.com/library/programming/build-a-simple-php-application
For the email sending I'm definitely using something that I did not write myself - PHPMailer. I don't think it even had me write an SMTP host or port, so that might definitely be the issue. I'll look into it more in depth tomorrow. It's pretty late here (:
Patrick Cooney
12,216 PointsIt could also be SMTP configuration on the part of the web host. Open SMTP ports are just begging to have spammers on your system. Some shared web hosting companies don't give you direct access to SMTP. First check your settings in your code as Patrick said, and after that, if it still doesn't work, I'd check with your web host.
Lea Marolt
5,127 PointsBut the email I'm setting to be sent to, aka where I should be getting these emails, is a gmail one.
Pavol Almasi
Courses Plus Student 1,524 PointsOK, when I sent empty (or incomplete) form, it gave me an error message but did not display the form anymore. It seems there is a problem with a conditional statement, that checks if the form has been sent and if any error was triggered. Basically something like: if (error) display error message and a form, else, display thank you message (and either the contact.php page or whatever other thank you page you may have).
When I submitted complete form but with a bad email, it displayed the error message, however that was the only thing on the page. So there seems to be a problem with the redirect - at this point there should be none. It should simply display the page as normal with and error message that the email address is invalid.
When the form was completed and sent, the page loaded OK with a thank you message, so this part works fine.
It's hard to pinpoint where the problem is without seeing the php code and how it is embedded with your HTML page, but I hope this helps (a little :-)
Lea Marolt
5,127 PointsActually... oddly enough, I got your email.
Lea Marolt
5,127 PointsOkay, for some reason... it just started working now. Don't quite know how. I changed the events that happen when there are errors, thanks for pointing that out (:
Lea Marolt
5,127 PointsLea Marolt
5,127 PointsThe website is hellosunschein.com, and yes pho should be running. And yes I've checked the spam folder (: