开发者

sending email from html using javascript without default outlook

I want to send an email using javascript without using the outlook. I don't want to use mailto object which use outlook for 开发者_如何学Gosending email.

Is there any direct method provided by JavaScript to send the data submitted in the form to an email address.


Kinda. At least, you have the possibility to do the following:

Via JavaScript, you can make a call to a server-based service which can dispatch an e-mail via SMTP. Whether this call is made via a simple form submission to your own server or via an XmlHttpRequest to a remote service is only a matter of a) whether you will implement it yourself and b) whether you're able to find a service elsewhere.

tl;dr:

  • JavaScript itself cannot dispatch e-mails
  • However, you can make JavaScript call a service which is able to "talk" SMTP.


It will be some work, but I think with Websockets you can get this to work.

You would then need to implement the SMTP protocol yourself:

http://www.smtp2go.com/articles/smtp-protocol.html

Here is a tutorial on websockets:

http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/

You may want to read through the websockets spec for more details:

http://dev.w3.org/html5/websockets/#the-websocket-interface

So, in theory you should be able to do this, but according to the specification SMTP is generally blocked from Websockets:

If port is a port to which the user agent is configured to block access, then throw a SecurityError exception. (User agents typically block access to well-known ports like SMTP.)

But, this is typically blocked, not always, or required, so it could possibly work, and is the only way I can see for javascript to send emails.


No.

Such a feature would be a security risk as it could be easily abused by spammers. To directly send an e-mail without opening up an instance of the user's default e-mail client, you have to pass the data to a server that will send the e-mail.


I think you should write a backend program which accept a email address and email content, then send the email. Then you can submit the form to the backend with Ajax in the browser.


I really hope there is no way to do this with client-side code, because I really don't want some random webpage using my PC to send emails without me knowing it.

And having said that, I'm sure the answer is "no" anyway.

The whole point of "mailto" is that it opens the user's default email program (not necessarily Outlook) so that they know they're sending an email and can edit all fields before continuing (assuming they want to continue at all).

The closest you can get that I can think of is for your JavaScript to make an Ajax call to your webserver and then send the email from your server-side code.


The mail program opened depends on what the default is set to on the individual client machine.

To send an e-mail without touching an e-mail program such as Outlook, Thunderbird etc then you need to use some kind of server-side language such as PHP and it is very easy to do aswell and there are plenty of resources out there so that you can achieve what you want to.


NO! JavaScript can’t email a form! but, there are alternatives to send the form data to an email address.

There is no direct method provided by JavaScript to send the data submitted in the form to an email address.

The main concern for not providing a ‘JavaScript email form’ feature is security. Suppose there is a feature in JavaScript to send email. Some malicious coder can write a script to send email to some address immediately when you visit their page. This will reveal your email address to some third party without your knowledge. They will start filling your mail box with lots of spam messages!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜