HTML CSS Javascript jQuery AJAX PHP Java MORE

How to send an email from JavaScript

<script src="https://smtpjs.com/v3/smtp.js"></script>

index.html

<!DOCTYPE html> 
<html> 

<head> 
<title>Send Mail</title> 
<script src= 
	"https://smtpjs.com/v3/smtp.js"> 
</script> 

<script type="text/javascript"> 
	function sendEmail() { 
	Email.send({ 
		Host: "smtp.gmail.com", 
		Username: "sender@email_address.com", 
		Password: "Enter your password", 
		To: 'receiver@email_address.com', 
		From: "sender@email_address.com", 
		Subject: "Sending Email using javascript", 
		Body: "Well that was easy!!", 
	}) 
		.then(function (message) { 
		alert("mail sent successfully") 
		}); 
	} 
</script> 
</head> 

<body> 
<form method="post"> 
	<input type="button" value="Send Email"
		onclick="sendEmail()" /> 
</form> 
</body> 

</html> 

what if you have multiple receivers. In that case you have to do nothing just configure your sendMail() function as

to: 'first_username@gmail.com, second_username@gmail.com',

Rest all we be same. If you want to send html formatted text to the receiver

html: "<h1>GeeksforGeeks</h1>
<p>A computer science portal</p>"

in order to send attachment just write the following code in sendMail() function:

Attachments : [{
    name : "File_Name_with_Extension",
    path:"Full Path of the file"
}]

index.html

<!DOCTYPE html> 
<html> 

<head> 
<title>Sending Mail</title> 
<script src="https://smtpjs.com/v3/smtp.js"></script> 
<script type="text/javascript"> 
	function sendEmail() { 
	Email.send({ 
		Host: "smtp.gmail.com", 
		Username: "sender@email_address.com", 
		Password: "Enter your password", 
		To: 'receiver@email_address.com', 
		From: "sender@email_address.com", 
		Subject: "Sending Email using javascript", 
		Body: "Well that was easy!!", 
		Attachments: [ 
		{ 
			name: "File_Name_with_Extension", 
			path: "Full Path of the file" 
		}] 
	}) 
		.then(function (message) { 
		alert("Mail has been sent successfully") 
		}); 
	} 
</script> 
</head> 

<body> 
<form method="post"> 
	<input type="button" value="Send Mail"
		onclick="sendMail()" /> 
</form> 
</body> 

</html>