Skip to content
Related Articles

Related Articles

Improve Article
How to use mailto in HTML ?
  • Last Updated : 28 Feb, 2020

Mailto link is a default way to sending a mail when the consumer wants to communicate or wants to give feedback, then by clicking the mailto link will open a default sending mail window. So we can use mailto which directs us to the mail once the form is submitted. Using mailto we can set the action field of the form and in this case, the web browser invokes the email client to send the form submission to the email address specified. Also, we can attach the Cc, Bcc, Subject, and body content also.

Syntax:

<form  method="POST" action="mailto: name@gmail.com"
          enctype="multipart/form-data">

Parameters: This attribute accepts seven parameters as described below:

  • mailto: This parameter holds the email receipent addres mail.
  • cc: This parameter holds another mail that will received the carbon copy of the mail, it is optional.
  • bcc: This parameter holds another mail that will received the blind carbon copy of the mail, it is optional.
  • subject: This parameter holds the subject of the mail, it is optional.
  • body: This parameter holds the content of the mail, it is optional.
  • ?: This paramter is the first parameter delimeter, it is optional.
  • @: This holds the other parameter delimeter, it is optional.

Below examples illustrate the mailto link in HTML:

Example 1:






<!DOCTYPE html>
<html>
<head>
    <title>Using mailto link</title>
    <style>
        h1 {
            color: green;
        }
          
        .container {
            width: 400px;
            border: 2px solid black;
            padding: 15px;
        }
    </style>
</head>
  
<body>
    <div class="container">
        <h1>Geeksforgeeks</h1>
        <b>Using mailto link</b>
        <form method="POST" 
              action="mailto: geeksforgeeks@gmail.com" 
              enctype="multipart/form-data">
            <div class="control">
                Name:
                <input aria-required=""
                       id="name"
                       type="text" />
            </div>
            <br>
            <div class="control">
                Ph no:
                <input aria-required="" 
                       id="mobile_number" 
                       type="tel" />
            </div>
            <br>
            <div class="control">
                Suggestion:
                <br>
                <br>
                <textarea rows="7" cols="30"
                          name="comment">
  
                </textarea>
            </div>
            <br>
            <div class="control">
                <input type="submit" 
                       value="Submit" />
            </div>
  
        </form>
    </div>
</body>
  
</html>

Output:

Example 2:




<!DOCTYPE html>
<html>
<head>
    <title>Using mailto link</title>
    <style>
        h1 {
            color: green;
        }
          
        .container {
            width: 400px;
            border: 2px solid black;
            padding: 15px;
        }
    </style>
</head>
  
<body>
    <div class="container">
        <h1>Geeksforgeeks</h1>
        <b>Using mailto link</b>
        <br><br>
        <a href="mailto:geeksforgeeks@gmial.com?
           cc=gfg@gmail.com&
           bcc=geeks@gmail.com
           &subject=Feedback from the geeks
           &body=Add what you want to suggest">
            Suggest your thought
            about us through mail
        </a>
        </form
    </div>
</body>
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :