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

PHP

Julian McNeill
Julian McNeill
9,445 Points

HELP! When testing a contact form?

Do the files have to be on the server for the the contact form to actually send an email

3 Answers

Kevin Korte
Kevin Korte
28,148 Points

Yes, as far as I know you can not test a contact form from a local server (ie a computer). If you put your file(s) that process and send the email on your live server, and make sure your form submits to those files even if the site files are still locally on your computer, the email should send.

An example of this would be if you were developing a wordpress site locally, and was using a plugin for a form like Contact Form 7, even though your site is still local, testing the form works and you'll get an email because it's using a live email server.

Chase Lee
Chase Lee
29,275 Points

I know there is a way to setup emails on your local server in the console. I believe the commands are:

sudo postfix start

mail

sudo postfix flush

sudo postsuper -d AL

Note: That last one might be sudo postsuper -d ALL.

Chase Lee
Chase Lee
29,275 Points

Follow the instructions on this site. If you have a Mac.

James Barnett
James Barnett
39,199 Points

Postfix is way overkill for this, usessmtp instead. Here's how to use PHP using SSMTP to deliver email

Julian McNeill
Julian McNeill
9,445 Points

Thanks a lot for the answers. I have one more question. I want a modal to popup after you hit submit on the contact form do I just replace the redirect if ($success) code?