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:johndoe@nowhere.com”>

Mailto Link To Multiple Addresses :-

<a href=“mailto:johndoe@nowhere.com, janedoe@nowhere.com”>

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:johndoe@nowhere.com?cc=janedoe@nowhere.com&bcc=chucknorris@nowhere.com”>

Mailto Link With Pre-Populated Subject Field :-

<a href=”mailto:chucknorris@nowhere.com?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:chucknorris@nowhere.com?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 Reply

Your email address will not be published. Required fields are marked *