Html form email
Here is an example of an HTML form that sends an email:
HTML Code:
<form action="mailto:[email protected]" method="post" enctype="text/plain">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea><br><br>
<input type="submit" value="Send">
</form>
Explanation:
- The
action
attribute specifies the email address that the form data will be sent to. In this case, it's[email protected]
. - The
method
attribute specifies the HTTP method to use when sending the form data. In this case, it'spost
, which is the default method for sending form data. - The
enctype
attribute specifies the encoding type for the form data. In this case, it'stext/plain
, which means that the form data will be sent as plain text. - The
input
elements are used to collect user input. In this case, we have three input elements:name
,email
, andmessage
. - The
textarea
element is used to collect a larger block of text input. - The
submit
button is used to send the form data to the specified email address.
Note: This is a basic example, and you may want to add additional features such as validation, error handling, and security measures to your form.
Security Considerations:
- Make sure to use a secure email address that is not publicly accessible.
- Use a secure method to send the form data, such as using a web server or a third-party service.
- Consider using a CAPTCHA to prevent spam submissions.
- Make sure to validate user input to prevent malicious code from being sent.
Best Practices:
- Use a clear and concise subject line for the email.
- Use a descriptive and accurate body for the email.
- Make sure to include a clear call-to-action (CTA) in the email.
- Consider using a confirmation email to confirm receipt of the form submission.
- Make sure to test the form thoroughly before deploying it to production.