2

So I want to enable a button to open the default email sender on the user's computer (eg Outlook) so they can send us a direct email.

How can I do this with bootstrap buttons and what is the best way to keep bots away.

Thanks

René Vogt
  • 43,056
  • 14
  • 77
  • 99
Meathead
  • 21
  • 1
  • 1
  • 4

2 Answers2

6

Just use a mailto link with the correct css style:

<a href="mailto:some@email.com" target="_blank" class="btn btn-primary">Email Us</a>
Steve
  • 20,703
  • 5
  • 41
  • 67
2

I was thinking to hide the mailto in javascript. Like below. I think the mail has to be obfuscated in the javascript code as well.

Read more about How to spamproof a mailto link?

Not obfuscated example

$(document).ready(function() {
  $('#mailbutton').click(function(event) {
    window.location = "mailto:example@example.com";
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<a href="#" id="mailbutton" class="btn btn-primary">Send us a mail!</a>
Community
  • 1
  • 1
Tom B.
  • 2,892
  • 3
  • 13
  • 34