Javatpoint Logo
Javatpoint Logo

mailto HTML Tag

A mailto link is the type of HTML hyperlink that redirects the programmer to a default mail client with a predefined recipient address. When the user clicks on the mailto to generate a link, the default mail client opens on the user's computer to send an email. The mail client has predefined parameters such as Cc, Bcc, subject and body content, that are used to send email to one or more recipients. For example, if your system has Microsoft Outlook, Google, Yahoo! Mail, Apple Mail, Thunderbird and other installed accounts, the mail client redirects it to you as you press a mailto link on the browser.

mailto HTML Tag

Syntax

Creating a mailto tag in HTML

To create a mailto link in HTML, we need to use the HTML <a> tag with its href attributes, and then use the mailto link.

Let's create a simple mailto program in the HTML.

mail.html

Output:

mailto HTML Tag

Click on the Click to send email link; it redirects to the installed mail account, as shown below.

mailto HTML Tag

In the above example, when we run the mail.html file on the Chrome browser, it shows a Click to send email link. After that, as we click on the link, it redirects us to the installed mail account to send an email, as the above image shows.

If we want to send an email to more than one user, we need to separate each address with a comma or & (Ampersand) symbol, as shown in the below syntax of the mailto tag.

In the above syntax, the mailto attributes can be arranged in any order, but ensure that the {email address) is first, and then a question mark directly follows it.

Properties of the mailto HTML Tag

Following are the various properties of the mailto html tag.

  1. mailto: It is the main parameter that specifies the recipient's email address, including optional parameters such as CC (Carbon copy), BCC (Blind Carbon Copy), the subject and body of the message.
  2. Email address: It is the main parameter of the mailto tag that defines the address of the recipient mail field.
  3. Cc: It is an optional parameter of the mailto tag that holds the address of another mail and is received by the recipient as a carbon copy of the mail.
  4. Bcc: It is an optional parameter of the mailto tag that holds the specific address of another mail and is received by the recipient as a blind carbon copy of the mail.
  5. Subject: It is an optional parameter of the mailto tag. It is used to write the subject of the mail.
  6. Body: It is an optional parameter of the mailto tag. It is used to fill or write the content for mail.
  7. ?: It is an optional parameter of the mailto tag that holds the first parameter of the delimiter.
  8. @: It is also an optional parameter of the mailto tag that holds other delimiter parameters.
  9. Clickable text or image: It is the HTML hyperlink field that is displayed to the user on the browser.

Example 2: Write a program to add multiple user addresses with subject and body using mailto tag in HTML to send an email.

mail2.html

Output:

mailto HTML Tag

Click on the Give feedback link; it redirects to the installed mail account, as shown below.

mailto HTML Tag

In the above image, we have added multiple user accounts, such as john@example, jtp@gmail.com and javatpoint@gmail.com, with the subject of email and body-content.

Example 3: Write a program to automatically populate CC, BCC, subject and body of mail using mailto tag in html.

mailto.html

Output:

mailto HTML Tag

Click on the Send your queries through mail link; it redirects to the installed mail account, as shown below.

mailto HTML Tag

In the above output, we have established a link to the Cc, Bcc, subject, and email body, which automatically populates visitors.

Example 4: Create a custom layout for sending an email using the mailto tag in the html.

mail5.html

Output:

mailto HTML Tag

After filling the form, click on the Submit button; it redirects us to the email account to send the message.


Next TopicHTML Counter




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA