top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How mail can be sent using Javascript?

0 votes
459 views
How mail can be sent using Javascript?
posted Jun 13, 2014 by Rahul Mahajan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Browser-side JavaScript cannot send email on its own. The best it can do is try to open the user's email application for them so they can send the email. For example:

location.href = 'mailto:' + encodeURIComponent(emailAddress) +
                '?subject=' + encodeURIComponent(subject) +
                '&body=' + encodeURIComponent(body);

You could hook the submit event of the form, prevent the default action, and execute that code, and the end result would be they could fill out the form, click submit, their email client opens, and they can click send.

answer Jun 16, 2014 by Deepak Negi
+1 vote

You can use JavaScript to execute a client side email program and send the email using the "mailto" code. Here is an example:

function myfunction(form)
{
tdata=document.myform.tbox1.value;
location="mailto:mailid@domain.com?subject=...";
return true;
}

answer Jun 16, 2014 by Karamjeet Singh
Similar Questions
+2 votes

Is there any way so that i will get to know about my variable is a number or not without using Javascript?

+2 votes

I know it is possible via IE (ActiveX objects).
Can we do this with all browsers ? (Specially in FireFox)

...