Atul Patel
Atul Patel

Reputation: 163

Can we send email from static html page?

I have created one html static inquiry form and i want to write a code on submit action in which when we click on submit, One email will send on my account.

How can i write a code in static html form to send email in static html page?

Upvotes: 2

Views: 5911

Answers (4)

Mark Santolucito
Mark Santolucito

Reputation: 63

Check out the answer posted here https://stackoverflow.com/a/34653647/1609406

tl;dr

<form action="http://formspree.io/[email protected]" method="POST">
  <input type="email" name="_replyto">
    <textarea   name="body">
    </textarea>
  <input type="submit" value="Send">
</form>

Upvotes: 0

atmd
atmd

Reputation: 7490

Unfortunately you cant automatically send a email from a html/static file, you would have to use some server technology to process the request and send the email.

its not to difficult to do though, so check out this tutorial from css tricks css tricks email in php tutorial

there is also the php docs here php.net docs for mail()

((The above is for PHP, see asp.net email if you are using asp.net (there is also node, java, python etc, but php and c#.net are all I have experience in)

There is always the option to use mailto

<a href='mailto:[email protected]'>send an email</a> // etc

However this will only open up the users email client, so could put some users off (as well as making it unusable for people without an email client (although it can be used to open up web based clients such as gmail)) so not ideal.

Upvotes: 0

Alex Howansky
Alex Howansky

Reputation: 53573

You can't do this with pure static HTML. You'll need to use some sort of server side scripting, via an embedded language like PHP/Python/Perl/Ruby/etc., or a CGI handoff to a custom executable.

Upvotes: 0

Quentin
Quentin

Reputation: 943615

Only HTTP(S) URIs are safe for use in form actions. You need a server side process to send email (even if it is an externally hosted, third party service). Attempts to do this purely client side are too unreliable to use.

Upvotes: 3

Related Questions