Reputation: 29
Can we send email from static website( html page)? without using asp.net or others(i mean no server side tech).
Upvotes: 1
Views: 16486
Reputation: 6136
You could do that, but you can't guarantee the result.
The following code is legit:
<form method="post" action="mailto:my_adress@my_website.com" enctype="text/plain">
<!-- some inputs here, with a submit of course -->
</form>
But before you do that, please read this. It will show you the dangers of using that.
Upvotes: 0
Reputation: 17471
With javascript and html alone, it's not possible. Javascript is not intended to do such things and is severely crippled in the way it can interact with anything other than the webbrowser it lives in. You can use a mailto: link to trigger opening of the users registered mail client.
However, you can do a popup window to make a better approach of mailto:
like this solution
var addresses = "";//between the speech mark goes the receptient. Seperate addresses with a ;
var body = ""//write the message text between the speech marks or put a variable in the place of the speech marks
var subject = ""//between the speech marks goes the subject of the message
var href = "mailto:" + addresses + "?"
+ "subject=" + subject + "&"
+ "body=" + body;
var wndMail;
wndMail = window.open(href, "_blank", "scrollbars=yes,resizable=yes,width=10,height=10");
if(wndMail)
{
wndMail.close();
}
EDIT: Maybe you can't use server side, but you can use the formmail.cgi
if your host provides one. Most hosts support this, and instructions for using FormMail are simple.
Upvotes: 1
Reputation: 2976
With no server-side coding, you have only one option to send email via HTML and that is
<a href="mailto:emailaddress">Email</a>
Upvotes: 0
Reputation: 2708
You can't send an email with just HTML (From the Front-End) unless you don't mind interacting with a third party service provider which can do the back-end process for you.
Otherwise, you need to use the Back-End, the most common and easiest way to do this is with PHP.
Upvotes: 0