0

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?

1
  • How is his problem related to PHP or CSS? What have you tried so far? Commented Apr 9, 2025 at 15:08

2 Answers 2

8

Just use a mailto link with the correct css style:

<a href="mailto:[email protected]" target="_blank" class="btn btn-primary">Email Us</a>
Sign up to request clarification or add additional context in comments.

1 Comment

What about bots? Dont really want to be spammed 24/7 Is there a way to distinguish them?
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:[email protected]";
  });
});
<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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.