A quick note: Sorry if it looks a bit crazy around here. I’m in the middle of tearing down my old theme and building a new one. In the meantime, you can watch me go through this very public process. (ha)

A standard mailto link in your e-mail or on your website causes the default e-mail program on the computer to open and create a new message. But what if the user uses Gmail instead? This causes a situation where the default mail client then has to be closed and a copy-paste operation has to be performed to get the desired result.

But what if you could have it both ways? What if you could give your readers the option of choosing to open the mail link in Gmail or their default mail client?

The Standard E-Mail Link

The usual e-mail link looks like this:

<a href=”mailto:name@domain.com”>E-mail me!</a>

What this says is to compose a new e-mail and put "name@domain.com" into the To: field.

Adding Additional Information

Did you know you can also make an e-mail link include a subject and some text in the body of the e-mail? But first you need to encode the information to work in an e-mail link. First, decide what you want to put into these fields. For this example, we’ll use:

Subject: Look here!

Body: Link – http://mysite.com/checkitout

Now we’ll take these pieces of info and encode them (one at a time) on this site. We’re now left with:

Subject: Look%20here!

Body: Link%20-%20http%3A%2F%2Fmysite.com%2Fcheckitout

Now we can put it all together in one line of HTML:

<a href=”mailto:name@domain.com?body=Link%20-%20http%3A%2F%2Fmysite.com%2Fcheckitout&subject=Look%20here!”>Send to a friend</a>

(try it)

Offering a Gmail Link

Now that you have created the info you need, you can now make a Gmail link. It looks like this:

<a href=”https://mail.google.com/mail/?view=cm&fs=1&tf=1&body=Link%20-%20http%3A%2F%2Fmysite.com%2Fcheckitout&su=Look%20here!”>Send to a friend via Gmail</a>

(try it)

But I Can’t Deal With Code!

No worries. You can insert a standard link in the WordPress editor and paste all of your href code between the quotation marks like this:

Insert Gmail Link


Feel free to ask in the comments below!

Pin It on Pinterest