Send Email Using Javascript or JQuery client side

Send Email Using Javascript or JQuery client side

Hi friends, I recently ran into a situation where I need to send email without any server side technology. So for using email using client side the only option was using javascript, jQuery or any client side library. But from JavaScript you are not able send emails directly because of security risk. I stucked around how to Send Email Using Javascript or JQuery client side.

I googled around this topic and found a nice piece of code with the awesome Mandrill App. Its a third party api, that allow you to send email using javascript and you don’t need to write any single link of server side code.

(Note: I dont know about Mandrill except for the fact that the first 12,000 emails per month are free.)

First of all add jquery library in your page. Then use the below script on your page.

$.ajax({
    type: "POST",
    url: "https://mandrillapp.com/api/1.0/messages/send.json",
    data: {
            'key': 'k-WxFhe95AY56u6uRo4EHw',
            'message': {
                         'from_email': 'darora85@live.com',
                         'to': [{
                                 'email': 'it.darora@gmail.com',
                                 'name': 'Deepak',
                                 'type': 'to'
                               }],
                          'autotext': 'true',
                          'subject': 'Hacked Email',
                         'html': 'This is test Email'
                       }
           }
}).done(function(response) {
      console.log("mail sent :" + response); // if you're into that sorta thing
});	

Preview of my mailbox:

preview Send Email Using  Javascript or JQuery client side
Preview Email using jquery

Hope this is useful. Friends I need you active participation in comments so that I can make this blog even better with lots of new content.

Now you can easiliy Send Email Using Javascript or JQuery client side without writing any single line of server side code.

Before using this code check mandrill app. This is recommended because I haven’t done this. I just googled this and found it was satisfying my requirement.

Thanks. Hope this is useful.

Cheers!!

Deepak Arora

Deepak Arora is a Software Developer and working continuously in this field from 2011. He work mainly with Microsoft Technology. He holds a Master's in Computer Application and he is MCTS certified person.

One thought on “Send Email Using Javascript or JQuery client side

Leave a Reply

Your email address will not be published. Required fields are marked *