[HTML5] Can I use HTML5 to send a client-side email?

摘要:[HTML5] Can I use HTML5 to send a client-side email?

http://stackoverflow.com/questions/5467395/can-i-use-html5-to-send-a-client-side-email

 

Question

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.

==============================================================================================================

 

Answer

Yes it is possible. But not practical ** See Edit 2  (可以,但是要用到些小賤招)

Some HTML5 implementations include support for websockets(websockets教學), essentially a tcp connection to a server. Overlay some send/recv code and you can build a SMTP client.

In fact it looks like nodejs and websocket support has been used to implement a smtp client ... see here ... (= =很硬的link)

You would still need a smtp server, username, password, etc just like a standard smtp client in order for it to work.

Using this method for spam would be unlikely as your smtp provider could easily cancel your account.

=== EDIT ===

Actually you could build a server less version, it would have to also implement name server lookups to find mx records. Chances are however that any decent SMTP servers maintain spamlist blacklist tables and connecting from an random ip address would see the email commonly marked as spam.

Also talking to smtp servers that require secure mail connections could be difficult.

As others have mentioned there are malicious uses to this implementation like sending spam. I guess it is possible you could be a HTML5 botnet creator but I would have thought that you would know most of this already :)

=== EDIT 2 ===

As Mark At Ramp51 mentioned, Handshaking is required with websockets. This was something I wasn't aware of. You would have to hack the websocket implementation to bypass handshaking.

The correct way is to have the web server forward the email.

=============================================================================================================================

 

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.

=============================================================================================================================

 

 

This is not possible.

Instead, you should use AJAX to send the email on the server.

 

=============================================================================================================================

You can't send the email using JavaScript alone. You'll need some form of server side processing (PHP, ASP, etc) to send the actual email.

There's a good tutorial on setting up an ajax form here: http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

It doesn't include the PHP (or ASP, etc) for sending the email, but there are plenty of tutorials out there for how to send an email using PHP.

 

=============================================================================================================================

You can't do it purely through client side code.

You can do it with a server callback, AJAX.

 

 

http://www.plurk.com/SophieQ