Can we send email from static html page? - html

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?

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.

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.

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:myemail#me.com'>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.

Check out the answer posted here
https://stackoverflow.com/a/34653647/1609406
tl;dr
<form action="http://formspree.io/your#email.com" method="POST">
<input type="email" name="_replyto">
<textarea name="body">
</textarea>
<input type="submit" value="Send">
</form>

Related

Is there any way to show feedback for a form submission without Javascript?

Let's say we have a basic HTML form like this:
<form action="#" method="post">
<input type="text" name="name">
<textarea name="message" id="message" rows="5"></textarea>
<button type="Submit">Submit</button>
</form>
When a user clicks on the Submit button, whatever is in the action attribute will happen without any javascript.
The question is, is there any way to show some kind of feedback based on the submission (either success or error) without javascript?
Also please note that the project is supposed to be hosted on GitHub Pages.
Short answer: no
You need to have some kind of programming language involved.
Typically a form will submit to the URL specified in the action attribute and the response will be handled by server-side programming. GitHub Pages only supports static files so that isn’t an option unless you combine it with a third party host for your server-side code.
You can also handle the data using client-side programming. This requires JavaScript (although you can write in some other languages, such as TypeScript, that you can transpile to JavaScript). Typically you would add a submit event listener to the form.
No. You must use some programming language.
However, if you're hosting the form,
Some hosts like Netlify will display a message once the message has been sent.

make HTML unchangeble

I'm learning to use a payment method via SCI.
and for that I have to send a POST/GET request to The SCI.
everything is working fine. the payment goes well.
but when I open the page and inspect it, I can see The input fields of the form. (type-->hidden) then using the edit HTML I can change the amount as you can see in the image bellow
<input type="hidden" name="amount_USD" value="60" readonly>
the readonly does not do the job! how can I make HTML Code unchangeable.
or if there is any alternative way to code this in a more secure way.
You can never make client side code completely protected, because there are many tools one can use to manipulate the files. Anything from browser extensions to developer tools can do this. Code that can be modified includes HTML, CSS, and client-side JavaScript.
If your app/website relies on this type of security, it will never be completely secure.
Chrome Dev Tools is only one example of a way some could maliciously use your app. You should evaluate your security practices from the back end to front end.
There is nothing you can do to prevent the user from being able to edit the HTML on client (browser). You should implement server side validation to reject invalid data.
You can read more about it here: JavaScript: client-side vs. server-side validation
In this particular case, you could do something that rejects the amount received from client if it doesn't match on the server. Or, do not receive the amount from the client at all, if the client should not be able to change it.

HTML website programming

I am starting a new business and am creating a basic website for displaying what it is about and its products.
I have started with an outline in HTML and CSS, but I have met on some trouble with adding submitting forms and adding a path to the links.
I have figured out how to make a basic form like this:
<form>
First name:<br>
<input type="text" name="firstname">
<br>
E-mail:<br>
<input type="text" name=„E-mail“>
</form>
But whenever I click the submit button the page gets an error and I am also not sure where the data would be stored. I have not yet set up the domain for the website so I am still doing this in my browser.
Also if I want to have a link to another page on my website such as:
Learn More
how do I add the path to the next page?
Thanks in advance!
You need to learn first how html works, and how to receive data with a server-side language (like php, java, asp, nodejs, etc).
To put a target to the form make something like this:
<form action="your-target-page.php" method="POST">
If you have a php server you can receive data:
$email = $_POST['email']
Learn more about form tag:
https://developer.mozilla.org/es/docs/Web/HTML/Elemento/form
Regarding the form you are going to need a server side language to handle the posting of a form. If you are new to website creation I would suggest using Wordpress and an already made free theme.
For your form this is better markup:
<form>
<label>First name:</label>
<input type="text" name="firstname">
<label>E-mail:</label>
<input type="text" name="email">
</form>
Assuming you have a file called learn_more.html in the same root that is how the link would work, target="_blank" opens it in a new browser window, if you just want it in the same window omit this.
Learn More
HTML form doesn't store any data with itself. It can just send a formed data to a server via HTTP protocol.
You need to have any kind of server side (CGI) program. Those are usually programmed in Perl, Python, Ruby, Java, PHP or so on.
In short
Send data to server side program from HTML form
Receive and process data with the program.

my form doesen't work right

I made a form but it doesn't send to my email; instead, it opens Windows Live Mail.
Here is my code:
<form name="name" action="mailto:someone#example.com" method="post">
What can I do to make the form send to my email instead of opening Windows Live Mail?
Your code IS good. Your code does exactly what it is supposed to do. When you submit a form with action attribute involving a mailto:, it opens up your email program to send an email to the someone#example.com address.
If you want the form to not send the email using the system's default mail program, you need to use something server-side. I don't know of any client side solutions, but who knows. There might be something out there...

How do i submit a form by email at the click of a button?

I have a script written to send an email of a completed form when I click a button but it doesn't work, here's the code:
<button type= "button" onclick= form action="mailto:Myemail#mail.co.uk">Submit</button>
where have I gone wrong? I'm aware that I don't have Outlook Express so if form action does not work without it, is there an alternative?
where have I gone wrong?
You are trying to use mailto: as a form action. It doesn't work.
You are trying to specify your action on a <button> instead of on a <form>
You are using a type="button" (which is for JavaScript binding) instead of type="submit"
is there an alternative?
Submit to a server side program, written in the language of your choice (that is supported by your server), and have it send the email. Third party hosted options are available.
If you want to open the email client on button click use this:
<input type="button" value="Submit" onClick="parent.location='Myemail#mail.co.uk';">
You do not need form action for that.
Another option is to write some kind of server side code that sends the email directly without having to open up the email client. You can write the code in variety of languages like PHP, ASP.NET etc.