Official EmailJS SDK for Browsers
SDK for EmailJS.com customers.
Use you EmailJS account for sending emails.
Disclaimer
This is a browser-only version, otherwise use
Links
Intro
EmailJS helps to send emails using client-side technologies only. No server is required – just connect EmailJS to one of the supported email services, create an email template, and use our SDK to trigger an email.
Usage
Install EmailJS SDK using npm:
$ npm install @emailjs/browser
Or manually:
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/@emailjs/browser@3/dist/email.min.js">
</script>
<script type="text/javascript">
(function () {
emailjs.init('<YOUR_PUBLIC_KEY>');
})();
</script>
Examples
send email
var templateParams = {
name: 'James',
notes: 'Check this out!'
};
emailjs.send('<YOUR_SERVICE_ID>','<YOUR_TEMPLATE_ID>', templateParams)
.then(function(response) {
console.log('SUCCESS!', response.status, response.text);
}, function(err) {
console.log('FAILED...', err);
});
send form
emailjs.sendForm('<YOUR_SERVICE_ID>','<YOUR_TEMPLATE_ID>', '#myForm')
.then(function(response) {
console.log('SUCCESS!', response.status, response.text);
}, function(err) {
console.log('FAILED...', err);
});
Angular X / VueJS / ReactJS
import emailjs from '@emailjs/browser';
const templateParams = {
name: 'James',
notes: 'Check this out!'
};
emailjs.send('<YOUR_SERVICE_ID>','<YOUR_TEMPLATE_ID>', templateParams, '<YOUR_PUBLIC_KEY>')
.then((response) => {
console.log('SUCCESS!', response.status, response.text);
}, (err) => {
console.log('FAILED...', err);
});