BBMAN225
BBMAN225

Reputation: 673

How do I make a simple email form submission in HTML?

I tried w3schools but it didn't help and I tried other websites too. I just wanna make a short html script that sends an email to an email address, but I keep reloading my email inbox and nothing comes up. Can you help?

<form action="MAILTO:[email protected]" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">

<input value="Submit" type="submit">
</form>

Upvotes: 3

Views: 13264

Answers (4)

ThadeuLuz
ThadeuLuz

Reputation: 922

I believe the easiest way to do this is using a service like Zapier or IFTTT. Both of them offer a way to create Zaps/Applets that can send an email when you post to a specific url.

This is what configuration would look like in IFTTT IFTTT and Zapier Zapier.

IFTTT is simpler to setup, Zapier has more options, like sending to more than one emails. I believe IFTTT only lets you send to your account's email.

Upvotes: 0

Siddharth Ram
Siddharth Ram

Reputation: 576

You are confusing a few things. When you Submit a form, it goes from the client (browser) to your server, which acts upon it. The form action needs to be a URL which handles the request. The mailto: URI scheme is not a valid action to use.

You have two choices:

You can create a mailto: link like this: Send email

which will open your default email client,

OR

  • You can put a URL corresponding to an end point on your server, something like

    form action="/send/mail"...

and have your server send the email

Upvotes: 2

SoWhat
SoWhat

Reputation: 5622

You need to use a server side script here. HTML alone won't help you here. HTML is just the frontend logic. You need some script on backend that accepts this data you submit and actually sends out an email. To take the example in PHP, assuming u have the server set up and all or that your shared

<form action="sendmail.php" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">

<input value="Submit" type="submit">
</form>

sendmail.php

$email=$_POST['email'];
$message=json_encode($_POST);
$receiver="[email protected]";
$mailer="[email protected]";

mail($email,"Message for enquiry or whatever",$message,  array("from"=>$mailer));

Upvotes: 4

user149341
user149341

Reputation:

There were, at some point, browsers that supported forms of this type. However, they're all gone now -- you will need a server-side script to send email. It's impossible to do using HTML alone.

Upvotes: 2

Related Questions