How To Use MailTo Syntax On A Webpage ?

The mailto URL scheme is used to designate the Internet mailing address of an individual or service. In its simplest form, a mailto URL contains an Internet mail address which upon clicking will launch the default mailing software on the computer.

 

mailto-syntax1

 

Sometimes we also require the message headers and body to populated as well, mailto syntax can also be used for that. Mailto command is generally used to link to a single email address but there is much more Mailto can do..

Basic Syntax :-

     mailtoURL  =  "mailto:" [ to ] [ headers ]
     to         =  #mailbox
     headers    =  "?" header *( "&" header )
     header     =  hname "=" hvalue
     hname      =  *urlc
     hvalue     =  *urlc

**Note :- Within mailto URLs, the characters "?", "=", "&" are reserved.

Some Other Lesser Known Mailto Syntax :-

Mailto Link To A Single Address :-

<a href=“mailto:[email protected]”>

Mailto Link To Multiple Addresses :-

<a href=“mailto:[email protected], [email protected]”>

By looking at the syntax above you would have got the idea that we can send the same mail to multiple persons by seperating the addresses using comma operator.

Mailto Link With Pre-Populated CC and BCC Fields :-

<a href=“mailto:[email protected][email protected]&[email protected]”>

Mailto Link With Pre-Populated Subject Field :-

<a href=”mailto:[email protected]?subject=I'm%20Invincible”>

In the syntax above if you want to include a space in your subject field then use %20 as whitespaces are automatically truncated.

Mailto Link With Pre-Definded Subject And Body Fields :-

<a href=”mailto:[email protected]?subject=I'm%20Invincible&body=Game%20Over″>

Reference

These were some of the lesser known mailto syntax’s you can use on your webpage. Do provide feedback or share this post if you like the information on this article. Cheers..

Leave a Comment.