Skip to content Skip to sidebar Skip to footer

Emailing From Javascript

I know this topic has been covered from all sorts of angles but I'm not sure I've seen the answer to my specific question. I am writing a prototype web page in HTML5, CSS, and Java

Solution 1:

Is there anyway to do this without having to mess with the server side?

Nope, not unless the target browser has exposes an SMTP client object. (And I don't think any do. That would make spam botnets quite a bit easier to build...)

You need to do this on the server.


Solution 2:

Email cant be sent just by client side . You must either use a mailto link if you want it on client side but that's not best way . Instead you should send a request to server and do server side processing .If you have SMTP credential you can send email with server side.


Solution 3:

I recently wrote a plugin for PostageApp that lets you send emails through jQuery. Basically, you just have to feed it your API key along with the message payload and you can send it through. With PostageApp, you can add your SMTP servers to the app and send through them.

Usage looks like this:

<script type="text/javascript" src="postage.js"></script>

<script type="text/javascript">

    $(function() {
        $('p').postage({ 
            apiKey: "API KEY HERE", 
            recipients: "recipient@email.com", 
            template: "TEMPLATE_SLUG" });
      });

</script>

I didn't publish the plugin because well... it never made sense for production usage because your API key was exposed and that's not a good thing. However, it is decent for prototyping (I use it!) and I would be happy to share.

(Full Disclosure: I am the Product Manager of PostageApp.)


Post a Comment for "Emailing From Javascript"