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

General Discussion

Travis Medeiros
Travis Medeiros
4,149 Points

I was wondering how to after filling in a form and pressing the submit button to send that data to me via email.

is there a class to take or can someone point me in the right direciton.

6 Answers

Chris Jones
Chris Jones
9,419 Points

You can use something like php sendmail, are you using a Virtual private server or a shared hosting provider (GoDaddy or 123-Reg or similar) or are you trying locally?

Wayne Priestley
Wayne Priestley
19,579 Points

Hi Travis,

If you just want to have the form sent to your email address you could use the mailto action.

<form action="MAILTO:someone@example.com" method="post" enctype="text/plain">

then your form contents

</form>

Chris Jones
Chris Jones
9,419 Points

Wayne Priestley, that would still require some form of SMTP, otherwise it won't be able to get outside of the local machine/server

Wayne Priestley
Wayne Priestley
19,579 Points

Hi Chris,

No, not in this case. When the user fills in all the information and hits the submit button their email client opens with a pre populated email containing all the info they entered.

They just hit send and its done.

Chris Jones
Chris Jones
9,419 Points

Yep, Wayne, I agree, but I guess it all depends on what the requirements would be from the OP.

If, for example, it was a contact form, I personally think it would be a bad user experience for them to fill out a form on a website and for that to then open the systems default mail client with duplicated content.

What if the site visitor only used web based mail and doesn't have a client installed or configured?

Wayne Priestley
Wayne Priestley
19,579 Points

Chris,

I wouldn't use this option either for the reasons you've said, but its an option thats there. I don't have a clue what Travis intends to do with the form so I don't know if it would work for him or not.

Travis Medeiros
Travis Medeiros
4,149 Points

I definitely want to avoid that bad user experience of filling out the form then a email program pops up. Is there a way to avoid the email program poping up? Can it just send the data on the form to me after they click the submit button?

Travis Medeiros
Travis Medeiros
4,149 Points

Sorry just read Christ Jones first post. So I may need to get into php then?

Wayne Priestley
Wayne Priestley
19,579 Points

Yes Travis, your going to need some sort of code such as pho to help you out.

Another option would be to use a third party form such as Machform

Travis Medeiros
Travis Medeiros
4,149 Points

Any classes that you would recommend that could help me?

Wayne Priestley
Wayne Priestley
19,579 Points

There are Database courses, php & Python all on treehouse.