Is it possible to create a contact form that sends the answers by email with only HTML5 and JavaScript? And if it is, how do I do it?
I don't think it's possible to do it from JavaScript directly via a mail function or so because the user's local machine can't be assumed to be running a mail server. There would be nothing to send the email from.
I'm not sure how "standards compliant" this is, but you can navigate to (by using links or document.location) to mailto:user#example.com or so which will begin composing an email in the user's standard email client, allowing them to send you an email directly. Though this will expose both their and your email address.
In the action field of the form, set the action as “mailto:youremailaddress” for example:
<form action="mailto:myforms#mydomain.com">
If you want to send the form data as plain text you can use the following
Add ‘enctype=text/plain’ in the form attributes. The form code becomes:
<form action="mailto:myforms#mydomain.com" enctype="text/plain" >
When this form is submitted, you will get the email in readable form.
Related
Basically i'm creating a website for a friend and he needs a "Contact Us Page", i'm using bootstrap studio and I have a page where you enter your name, and email. But i'm having trouble with the next part. I need the page to open the client's default email program to compose to a certain address with the entered name and email already in it how would one go about this?
simply do something like this
Click Here To Email!
if you want the email to be sent via a form submission you either need to setup a backend that will do that or you can use a service like https://formspree.io/
I've used them before, but I'm not certain what they're rules are about data privacy so its really up to you.
I have HTML form with a textbox where user enter his email - let say to register for a newsletter and a button to join.
When clicking the button I'd like to send myself an email with a constant subject like: 'a new user joined your newsletter' and in the body of the email have the text entered by the user.
So with PHP and Javascript code its possible - i'm looking for a pure html code that does the same (in my index.html file)
using <a href: mailto...> or <form action=mailto:... method=post> or <button onclick:mailto...> opens my mail application :(
Is there a way to send that email in the background (without opening the mail application) with the data from textbox in the email body?
if Yes to Q.1 then is there a way to add a fixed subject
No, there is no way you can send email using pure html. Email is sent over SMTP protocol. A browser operates in HTTP protocol. So it's not possible to send email even using pure javascript. Only server can send data using SMTP protocol.
No because you can not send an E-Mail without using an SMTP server. This server must be contacted by PHP or another server-side script (server must receive a form request and process it). You can not contact a SMTP server via pure HTML (that would be really insecure btw).
Regarding mailto: This only works if your clients have installed a mail client on their local machine. This mail client must be properly configured in order to - guess what - contact an SMTP server in order to send the mail.
However it is possible passing a subject via mailto:
https://css-tricks.com/snippets/html/mailto-links/
So i am running a JX Browser which allows content to be shown in an iframe. When someone logs into my ticketing software i want to post their username and password to another form in an iframe.
Basically the iframe contains a page in which i want them to be automatically logged in to. The login credentials for the ticketing software and the page are the same all i want to do is pass that credential to an iframe in which there is username and password field.
Like in jquery you can get .val of the what every is submitted and just send it to another form field.. i want to do that..
What is the best practice?
You can set target attribute on a form to point it to an <iframe> by name.
For example:
<form action="process_login_url" method="post" target="iframelogin" id="loginform">
<input name="login" type="hidden" value="login" />
<input name="password" type="hidden" value="p4ssw0rd" />
</form>
<iframe name="iframelogin">
<script>
// automatically post the form
document.getElementById('loginform').submit()
</script>
You need to pre-populate the hidden fields with user login and password, then the form is automatically sent to the iframe. action on your form has to be the other login processing url, not the login form itself (if these are separate). So basically the action attribute of the external form. Names of the input fields also have to match the target form's names.
Example: http://jsfiddle.net/297suggf/2/ - note the iframe has no src attribute, it loads the url from action on the form with the POST data passed with the request. (It's some random website that allows testing POSTs).
I don't think it's a great idea, and it may not work if there's a protection on the receiving end (like a CSRF token), but youu may give it a shot if it's a last resort type situation
I am sending simple html templated emails to users, now i want to include text box and submit button in my email template. user can put text in textbox in email and submit data, that data will save in my database. How can i do this? any suggestions?
Add a link in your email content to redirect on the form in browser.
Look on this website to understand why put a form in an email is not good way : Send a Form via Email
Add a link to redirect them to browser form is nicer, and you can add some variable at the URL to recognize the user too like http://testingsite.com/form?user=xxx, so that u can know who is the user and pre-filled date or them.
I'm sending form data to an iframe (<form target="myIframe" ... >) because I need to upload a file and because I don't want to reload the page.
The problem is that I need to encrypt some data of the form. Surely I can replace values in form with encrypted values but it would not be really user-friendly. Is there some kind of callback to adjust the data of submitted form in javascript/jQuery?
Thanks!
Just use SSL.
<form action="https://..."
You need to load the page that displays the form via SSL to, otherwise it can be interfered with by a man-in-the-middle attack.