Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Julian McNeill
Julian McNeill
9,444 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,135 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,444 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?