1.

How to use mailto to send mail in HTML form?

Answer»

A common feature of any website, even the most basic static site is a Contact Us form. Here, the user will enter his/her basic information and when clicked on Submit, it will send an email to us.

This feature can be implemented very easily using mailto in attribute action of a form. Below is a SIMPLE Contact Us form containing this mailto.

<!DOCTYPE html> <html> <head>    <title>Code Demo</title>    <style>        .grid__iframe {            display: grid;            place-content: center;        }    </style> </head> <body>    <DIV class="grid__iframe">        <h1>Contact Us</h1>        <form enctype="text/plain" method="post" action="mailto:someone@someone.com">            Your FIRST Name: <input type="text" name="first_name"><br>            Your Last Name: <input type="text" name="last_name"><br>            COMMENTS: <br>            <textarea ROWS="5" cols="35" name="comments"></textarea>            <br>            <input type="submit" value="Send">        </form>    </div> </body> </html>

It uses your local email client of the computer to send an email, once we click on submit. On a Mac, it will open the default “Mail” client as shown in the screenshot.



Discussion

No Comment Found