How to send an email from JavaScript

0 votes

I want my website to have the ability to send an email without refreshing the page. So I want to use Javascript.

<form action="javascript:sendMail();" name="pmForm" id="pmForm" method="post">
Enter Friend's Email:
<input name="pmSubject" id="pmSubject" type="text" maxlength="64" style="width:98%;" />
<input name="pmSubmit" type="submit" value="Invite" />

I want to call the function like this, but I have no idea what to put within the javascript code. 

I discovered one example using the mailto technique in my study, but from what I can see, it doesn't really transmit from the website.

In order to send an email directly from a website, my question is where I can locate the code to insert within the JavaScript function.

function sendMail() {
    /* ...code here...    */
}
Nov 7, 2022 in Java by Nicholas
• 7,760 points
709 views

1 answer to this question.

0 votes

Javascript does not natively support email sending.

However, you may access the user's mail client:

window.open('mailto:test@example.com');

There are also some parameters to pre-fill the subject and the body:

window.open('mailto:test@example.com?subject=subject&body=body');
answered Nov 8, 2022 by Damonlang
• 700 points

Related Questions In Java

0 votes
1 answer

How to pass an object from one activity to another on Android

One option could be letting your custom ...READ MORE

answered Jun 25, 2018 in Java by Rishabh
• 3,620 points
4,856 views
0 votes
3 answers

How to rotate an array from a particular index?

Muchas gracias. ?Como puedo iniciar sesion? READ MORE

answered May 2, 2020 in Java by oisoucknfn
2,130 views
0 votes
1 answer

How to remove object from an Array?

Here is a code I came up ...READ MORE

answered Mar 11, 2019 in Java by Esha Gupta
673 views
0 votes
1 answer

How to pass an object from one activity to another on Android?

Hello @kartik, Implement your class with Serializable. Let's ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,840 points
772 views
0 votes
1 answer

Presenting docket dtates inside html page by javascript

Use the Docker Engine Api:Docker Engine API ...READ MORE

answered Jun 20, 2018 in Docker by DareDev
• 6,890 points
733 views
0 votes
1 answer

Migrating proxy npm repo in nexus 3

I don't think you can achieve this ...READ MORE

answered Jun 22, 2018 in DevOps Tools by DareDev
• 6,890 points
1,520 views
+1 vote
1 answer

What is the difference between JavaScript and Java

This quote rightly explains that 2 totally ...READ MORE

answered Jun 29, 2018 in Java by Daisy
• 8,140 points
788 views
0 votes
1 answer

How to get current formatted date dd/mm/yyyy in Javascript and append it to an input

The stringent equality operator (===) works exactly like the abstract equality operator (==), with the exception that no type conversion is performed, and the types must be the same to be regarded equal. Javascript Tutorial on Comparison Operators After performing any required type transformations, the == operator will check for equality.  Because the === operator does not perform the conversion, it will simply return false if two values are not of the same type.  Both are equally fast. "abc" == new String("abc") ...READ MORE

answered Nov 4, 2022 in Java by Damonlang
• 700 points
1,473 views
0 votes
1 answer

How to filter an array from all elements of another array

This is what I would do: var arr1 = [1,2,3,4], ...READ MORE

answered Nov 7, 2022 in Java by Damonlang
• 700 points
4,183 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP