html button that opens gmail compose?

3.5k Views Asked by At

I want a contact button on my website in which when the user clicks the Gmail compose mail open in Gmail site with an email address. anyone have any idea how to achieve this?

2

There are 2 best solutions below

0
On

I did an example with the solution of Open Gmail on mailto: action

$('#go').click(function(event){
var email =  $('#email').val();
if(email)
window.location.href = 'https://mail.google.com/mail/?view=cm&fs=1&to='+email;
else
alert('please enter your email');
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>Please Enter Your Email And Go</span>
<br />
<input id="email" />

<button id="go">Go!</button>

0
On

Use this and style it according to you

<a href="mailto:[email protected]">Link text</a>