To send email from JavaScript provide us easiness to not configure own server for this task, let consider a small static website having a contact form, generally for this form developer have to set up some server for receiving email from that contact form. Now it is easy to receive that email through JavaScript easily. So follow the article to learn
Email sending configuration on mailjs
First of all, go to https://emailjs.com and create an account, if you have already an account then sign in.
![send email form javascript dotcode](https://dotcodeofficial.com/wp-content/uploads/2021/04/add-service-dotcode.jpg)
Then select the type you want to use, for this example I will select Gmail
![send email from javascript dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/connect-account-dotcode.jpg)
This asks for authentication and allow the Gmail account to send emails for this service.
![send email from javascript dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/allow-gmail-dotcode.jpg)
After allowing this the account will be connected with emailjs.com then click on create service, the service will be created and now it will be possible to send email from JavaScript.
Now as my service is created, now I will create an email template for sending emails through JavaScript.
![](http://dotcodeofficial.com/wp-content/uploads/2021/04/serivce-added-for-sending-email-from-javascript-dotcode.jpg)
For creating a template go to the Email templates tab and click on create new, This will be the actual template for viewing an email that was received through JavaScript.
![send email from javascript dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/create-email-template-to-send-email-through-javacript-dotcode.png)
This will create a default template, if you want to make some changes you can.
In the Content tab, I put my email address which will be used as my email address for sending.
![send email from javascript dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/email-tempate-view.png)
Then navigate to the Setting tab and give some name to the template and save it.
Integration with own code
After saving the template now it is time to send an email through JavaScript. Click on Playground to see the code.
![template create emailjs dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/go-to-playgoud.jpg)
Then copy HTML from there to put in HTML and JavaScript to put in your code.
![email js playground](http://dotcodeofficial.com/wp-content/uploads/2021/04/send-email-with-javascript-playgorund.jpg)
There are methods available for different development environments. In
![integration of email js](http://dotcodeofficial.com/wp-content/uploads/2021/04/integration-dotcode.jpg)
For plain JavaScript follow the browser tab and paste the script into your code.
Here is the preview of my implementation of code
![send email from javascript dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/email-form.jpg)
![success alert dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/alert-on-success-javascript-email.jpg)
![send email from javascript dotcode](http://dotcodeofficial.com/wp-content/uploads/2021/04/email-received.jpg)
You can download my code which you can see in the above design from github.com/bakarfreelancer/email-js
The emailjs.com provide 200 email fee per month. That is more than enough for startups and small businesses.
So that was all about sending emails from JavaScript. Enjoy!