0

I am making a website and I want one of the pages to have a form where they write their contact information and then have it sent to me when they press the submit button. I tried doing it in HTML by using this code

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

And then I have the form entries and a submit button. I enter some random details but it never sends me an email.

Here's my form entries if it means anything

Name:<br>
<input type="text" name="name" value="your name"><br>
E-mail:<br>
<input type="text" name="mail" value="your email"><br>
Comment:<br>
<input type="text" name="comment" value="your comment" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">

</form>
Zover69
  • 21
  • 4

1 Answers1

0

As others stated in comments above, you're mixing up 2 things. You have 2 options going forward.

  1. Option 1 is using a server-side language like PHP to send the e-mail. This is a bit harder to do, but it allows you to have a form on your page like you describe in your question. In this case, you'd have to change the action attribute of the <form> to the path to the (PHP) page/file that will process the POST request. Here's a tutorial on how to send e-mail in PHP.

  2. Option 2 is to get rid of the form and replace it with a link that will boot the user to his e-mail program with the To: field already filled out. Obviously, this will only work if the user has a local e-mail program set up. It's usually not compatible with webmail (like Gmail, Outlook.com...). However, it can be implemented in a single line of code:

Should you opt for option 2, you can just replace the <form> element with the following code snippet, which will produce the link:

<a href="mailto:your-address@example.com">your-address@example.com</a>

Note that in the snippet above, I repeated the e-mail address as the text of the <a> tag. This ensures that people who use webmail can copy-paste the e-mail address in the web app.

DriesOeyen
  • 483
  • 6
  • 13