2

For my website, I want users of the website to be able to ask me a question, and it get sent to my email. I've used this HTML:

<form method="post" action="mailto:blank@blank.com" >
  <input type="submit" value="Submit" /> 
</form>

I can't find any answers to this. All I find is, "You can't" and code that doesn't do anything.

Andrew Regan
  • 5,087
  • 6
  • 37
  • 73
  • 1
    `Send me an email` - This link should open up the users default email client and populate the adress field with `blank@blank.com`, they then need to enter a message and send the email. If you would like your users to compose a message and send it directly from your site, then you need to use some kind of server side language such as php. Here is an example: http://stackoverflow.com/questions/5335273/how-to-send-an-email-using-php – Cyclonecode Apr 02 '16 at 21:59
  • @Cyclone I have a form where users would fill out their name, message, email etc. Is there a way that I could get an email from the email they typed in the 'email' section of the form? – DiamondAppleGal Apr 02 '16 at 22:03
  • 1
    You need to submit the form and handle it on the server, for instance using a server side language such as php. `if (isset($_POST['message'])) { mail('blank@blank.com', '', $_POST['message']); }`. This cannot be done just using html. – Cyclonecode Apr 02 '16 at 22:05

4 Answers4

1

To make a page where customers, clients or consumers can send you a message from the page itself, you would need to involve/include PHP.

If you just wish to make a button to open the users email client when they click it, whether it's Gmail on an Android, Outlook on a Windows PC or Mail on iOS, the following code will place your email address, or whichever email address you specify, into their 'To' or 'Recipients' section in their email client.

<a href="mailto:your@email.com">Click here to email me</a>

You are using just a standard <a></a> tag but you are putting mailto:, fiollowed by an email address, in the href attribute. There are a few other you can use - you can see them, here.

You can add in other things to your mailto: link:

  • CC and BCC (carbon copy and blind carbon copy) - <a href="mailto:your@email.com?cc=mother@email.com&bcc=father@email.com">Click here to email</a>
  • Subject - tell the recipent a little bit about the email befroe they read it - <a href="mailto:your@email.com?subject=This%20is%20just%20an%20email%20to%20say%20hi%20:)">Click here to email</a>.
  • Body - this is the mail part of the email - <a href="mailto:your@email.com?body=Hello%20friend">Click here to email</a>

Please, ensure that for every space you wish to put in for the subject or body, put %20 instead. %20 is URL Encoding.

Josh Murray
  • 619
  • 5
  • 18
  • So you don't think some other server side language will do? – Cyclonecode Apr 02 '16 at 22:08
  • In all honesty, I have only ever used PHP to send emails from websites. So, unfortunately, I cannot answer that question. – Josh Murray Apr 02 '16 at 22:10
  • I tried downloading PHP and I got an error that said, "vcruntime.dll is missing from your computer." – DiamondAppleGal Apr 02 '16 at 22:18
  • @DiamondAppleGal: due to PHP being a server side language and your browser only being able to understand client side languages, you'll have to download something that will make your computer a server as well as a client. You can download WAMPServer (http://www.wampserver.com/en/), which I personally really like. There are more such as XAMPP but WAMP seems to work best for me. Once WAMP is installed, you will be able to use PHP. PHP also requires the Windows Redistributable packs, located here (https://support.microsoft.com/en-gb/kb/2977003). – Josh Murray Apr 02 '16 at 22:22
  • Did you get WAMP or XAMPP? – Josh Murray Apr 02 '16 at 22:44
  • I got WAMP, and nothing's happening. – DiamondAppleGal Apr 02 '16 at 22:55
  • At the bottom right of your screen, in your system tray or notification area, there should be a WAMP icon when you start the program. It should be green BUT if it is amber/orange or red it means it isn't starting properly. Please, look at some other StackoverFlow questions as there are bound to be some help with fixing WAMPServer. – Josh Murray Apr 03 '16 at 08:58
0

The only way to send an e-mail with pure HTML and no PHP is to use the a element. Use the href property with the value "mailto:email@address.com".

The only issue is that this will open their default mail client and they will have to manually click send via their mail client. As stated earlier PHP can accomplish this without opening the mail client.

Mozilla Documentation

<a href="mailto:someone@example.com?Subject=Hello%20again">Send Mail</a>
Wowsk
  • 3,637
  • 2
  • 18
  • 29
0

Would the HTML <button> tag work for you?

Start with your <a>nchor tag. Be sure to include your href="mailto:blank@blank.com"

<a href="mailto:blank@blank.com><button type="submit">Submit</button></a>

David
  • 11
  • 2
0

Well, I don't have an exact answer to making that happen in HTML but there is a much easier workaround. Services like https://formsubmit.co/ (free) and https://formspark.io/ (freemium) essentially let your users fill a form and send it to your email using API calls. one of the main downsides that I have noticed is that there is generally some sort of redirection or bot-spam filtering and I haven't successfully been able to avoid both at the same time. I hope this was helpful!