Search code examples
phphtmlcssformsmailto

Is it possible to use the mailto function to submit a form or is it only possible through PHP/JS?


I'm very new to html/css and I'm doing the Survey page exercise on FCC. I wanted to try to make the submit button actually work, and send the form information to my email, but it isn't working.

This is the code I'm using:

<form action="mailto:[email protected]"  method="POST" enctype="text/plain">
<button id="submit" type="submit">Submit</button>
  </form>

I've read other threads and have seen people suggest using PHP/JS, but as I'm not there yet on my lessons, is there any way to create a working "submit form" function that sends all filled input to my email?

Or should I not worry about it now and wait to learn PHP?

Thank you in advance for any help.


Solution

  • mailto: URLs for <form> actions are highly unreliable as they depend on the user having an email client, which the browser can successfully communicate with, set up for the user's mail service, and set as the default for the system. They also depend on the user confirming the sending of the email in their email client.

    For anything remotely reliable you need to submit the data over HTTP (preferably HTTPS) and process it on a server.

    You can process it with PHP or any other programming language (limited only by what your hosting allows). You can write your own program, host a program written by a third-party, or use a third-party service to send the email (which would mean submitting the data to a third-party URL).