I want to send an email in HTML5. I don't want to force the user to open a mail client, I want to send the email directly from the web page.
On a side note, is there any way at all to do this in JavaScript? I know it's probably not possible, just wondering if there are any crafty ways to pull it off going completely through the client.
In HTML5, two client-side storage facilities have been added: web storage, which includes session and local storage, and database storage. In this article, you will learn about these new client-side storage options and work through some recipes to get you started with storing data locally in the browser.
The mailto link is the easiest way to send an email from a front-end Javascript app. Put the email address you're sending to after mailto: as part of the string. When the user clicks on the anchor element, mailto will open the user's default email client and populate the “recipient” field with the intended email.
You can't send emails using JavaScript code alone due to lack of support for server sockets. For this, you need a server-side language that talks to the SMTP server. You can use JS in conjunction with a server script that will send emails from the browser based on your requests.
In short NO not directly from the client (excluding hacks).
you could make an ajax call to your server and send an email.
the problem with doing it from the client and not using a mail client is complicated. For example most consumer ISPs have their own SMTP relay that all outbound mail on port 25 must be transmitted over. You website will have trouble obtaining the proper information to do this. Secondly the webbrowser doesn't understand the SMTP protocol and neither does the XMLHttpRequest object.
So if you are a hacker ninja, maybe you can figure something out with ActiveX, Java Applets, or flash, but you basically would have to be operating directly with a tcp socket and issuing SMTP protocol commands over that socket.
There are many obstacles to overcome, in fact I don't know how to do it, but where there is will there is a way. Don't be surprised that if you do find a hack, it may be plugged swiftly by the major browser vendors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With