EmailJS helps sending emails using client side technologies only. No server is required.
The EmailJSResponseStatus model is explicitly exported to detect the error instance.
import emailjs from '@emailjs/browser';
try {
await emailjs.send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID');
console.log('SUCCESS!');
} catch (error) {
if (error instanceof emailjs.EmailJSResponseStatus) {
console.log('EMAILJS FAILED...', error);
return;
}
console.log('ANOTHER ERROR', error);
}
Conceptually, all input or output in JavaScript is an asynchronous operation, except for localStorage. To simplify work with the custom storage solutions, we've used the asynchronous localStorage.
Officially, this package was created only for browsers, but we have reworked the use of localStorage so this package can be used with Native React (partial functionality).
The API requests are migrated to use the Fetch API. The old browsers that do not support this API are not officially supported anymore.
Instead of a public key string, the parameter is now an options object. This parameter has supported compatibility but is outdated. Please take a look at the documentation for more details.
Client-side implementation. It blocks requests sent before the timeout expiration. The advantage of this configuration on the client side is that it does not use the account quota.
Client-side implementation. There are settings in the options where SDK users can specify unwanted variable values. Such requests will be rejected. This is useful for blocking specific email addresses, IP addresses, and other values.