{"id":135320,"date":"2025-11-06T10:19:54","date_gmt":"2025-11-06T10:19:54","guid":{"rendered":"https:\/\/phppot.com\/?p=24507"},"modified":"2025-11-06T10:19:54","modified_gmt":"2025-11-06T10:19:54","slug":"send-email-from-react-using-emailjs-no-backend-required","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2025\/11\/06\/send-email-from-react-using-emailjs-no-backend-required\/","title":{"rendered":"Send Email from React Using EmailJS (No Backend Required)"},"content":{"rendered":"<div class=\"modified-on\" readability=\"7.1489361702128\"> by <a href=\"https:\/\/phppot.com\/about\/\">Vincy<\/a>. Last modified on November 13th, 2025.<\/div>\n<p>EmailJS is a cloud service that supports to enable the frontend to send email without any backend. All we need is to create an EmailJS account and configure it to the frontend application.<\/p>\n<p>This tutorial shows the step-by-step procedure to learn how to enable <a href=\"https:\/\/phppot.com\/laravel\/how-to-send-email-via-laravel-sendmail-mailer\/\">email sending<\/a> in a React application using EmialJS.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-24642\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/send-email-from-react-using-emailjs-550x288.jpeg\" alt=\"Send Email From React Using EmailJS\" width=\"550\" height=\"288\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/send-email-from-react-using-emailjs-550x288.jpeg 550w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/send-email-from-react-using-emailjs-300x157.jpeg 300w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/send-email-from-react-using-emailjs-768x402.jpeg 768w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/send-email-from-react-using-emailjs.jpeg 1200w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<h2>Steps to allow EmailJS to send mail<\/h2>\n<h3>1. Signup with EmailJS service<\/h3>\n<p>First <a href=\"https:\/\/dashboard.emailjs.com\/admin\" target=\"_blank\" rel=\"noopener\">signup and login with EmailJS dashboard<\/a>. It\u2019s a free and enables mail sending via various services supported.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-24628\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/select-email-sending-service-550x522.png\" alt=\"Select Email Sending Service\" width=\"550\" height=\"522\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/select-email-sending-service-550x522.png 550w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/select-email-sending-service-300x285.png 300w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/select-email-sending-service.png 600w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<h3>2. Choose service provider via <em>Add New Service -&gt; Select Service<\/em><\/h3>\n<p>It supports various services like Gmail, Yahoo and etc. It also have settings to <a href=\"https:\/\/phppot.com\/laravel\/send-email-in-laravel\/\">configure custom SMTP server<\/a>&nbsp; with this online solution.<br \/><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-24632\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/permit-emailjs-to-access-mail-account-550x301.png\" alt=\"Permit EmailJS To Access Mail Account\" width=\"550\" height=\"301\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/permit-emailjs-to-access-mail-account-550x301.png 550w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/permit-emailjs-to-access-mail-account-300x164.png 300w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/permit-emailjs-to-access-mail-account-768x420.png 768w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/permit-emailjs-to-access-mail-account.png 1200w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<h3>3. Design mail template by <em>Email Templates -&gt; Create New Template -&gt; Select Template<\/em><\/h3>\n<p>There are various built-in templates in the EmailJS dashboard. I selected the <a href=\"https:\/\/phppot.com\/php\/html-contact-form-template-to-email-with-custom-fields\/\">\u201cContact Us\u201d template<\/a> for this example.<\/p>\n<p>Template edit interface has the option to change the design and the content. It allows to add dynamic variables as part of the mail content.<\/p>\n<p>When calling the EmailJS service, the request will have values to replace this variables. This feature will help to send a personalized email content.<\/p>\n<p>Copy the Template ID once created an email template.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-24630\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/design-emailjs-template-550x296.png\" alt=\"Design EmailJS Template\" width=\"550\" height=\"296\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/design-emailjs-template-550x296.png 550w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/design-emailjs-template-300x162.png 300w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/design-emailjs-template-768x413.png 768w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/design-emailjs-template.png 1200w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<h3>4. Get EmailJS API Public Key<\/h3>\n<p>Added <strong>Service ID<\/strong>, <strong>Template ID <\/strong>the EmailJS <strong>Public Key<\/strong>&nbsp; is also need to initiate the library class from the frontend React App.<\/p>\n<p>Navigate via Account using the left menu to open the API keys section. Copy <strong>Public Key<\/strong> from the EmailJS dashboard.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-24631\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/get-emailjs-account-public-key-550x296.png\" alt=\"Get EmailJS Account Public Key\" width=\"550\" height=\"296\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/get-emailjs-account-public-key-550x296.png 550w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/get-emailjs-account-public-key-300x162.png 300w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/get-emailjs-account-public-key-768x413.png 768w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/get-emailjs-account-public-key.png 1200w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<h2>Initiate EmailJS library to React App<\/h2>\n<p>Create a React app and install the EmailJS library to it using this command.<\/p>\n<pre class=\"prettyprint\"><code class=\"language-make-file\">npm install emailjs-com\n<\/code><\/pre>\n<p>This example code contains this library installed. So, just run <code>npm install<\/code> to bring the dependancies into your <code>node_modules<\/code>.<\/p>\n<p>Then, import the emailjs-com to the React JSX and initiate the EmailJS service as shown below. This script shows how the <code>emailjs<\/code> instance is used in the form handle submit.<\/p>\n<pre class=\"prettyprint\"><code class=\"language-make-file\">import emailjs from \"emailjs-com\"; const handleSubmit = (e) =&gt; { e.preventDefault(); const SERVICE_ID = \"Your Serivce ID\"; const TEMPLATE_ID = \"Your Template ID\"; const PUBLIC_KEY = \"EmailJS API Public key here\"; emailjs .send(SERVICE_ID, TEMPLATE_ID, formData, PUBLIC_KEY) .then(() =&gt; { toast.success(\"Email sent successfully!\", { position: \"top-center\" }); setFormData({ name: \"\", email: \"\", message: \"\" }); }) .catch(() =&gt; { toast.error(\"Failed to send email. Please try again.\", { position: \"top-center\", }); }); };\n<\/code><\/pre>\n<h2>Example React form to send email<\/h2>\n<p>This example provides component for the email sending form fields. The fields UI code is moved to a separate file and made as a component. It is imported into the parent container in the EmailForm component.<\/p>\n<p>It renders Name, Email and Message fields. Each fields is validated with a <code>handleChange<\/code> hook.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-24514\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-send-mail-form-550x383.jpg\" alt=\"react send mail form\" width=\"550\" height=\"383\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-send-mail-form-550x383.jpg 550w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-send-mail-form-300x209.jpg 300w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-send-mail-form-768x534.jpg 768w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-send-mail-form.jpg 1146w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<p class=\"code-heading\"><code>src\/components\/EmailFormFields.jsx<\/code><\/p>\n<pre class=\"prettyprint\"><code class=\"language-jsx\">const EmailFormFields = ({ formData, handleChange }) =&gt; {\nreturn ( &lt;&gt; &lt;div className=\"form-group\"&gt; &lt;label className=\"form-label\"&gt;Name&lt;\/label&gt; &lt;input type=\"text\" name=\"name\" value={formData.name} onChange={handleChange} className=\"form-input\" required \/&gt; &lt;\/div&gt; &lt;div className=\"form-group\"&gt; &lt;label className=\"form-label\"&gt;Email&lt;\/label&gt; &lt;input type=\"email\" name=\"email\" value={formData.email} onChange={handleChange} className=\"form-input\" required \/&gt; &lt;\/div&gt; &lt;div className=\"form-group\"&gt; &lt;label className=\"form-label\"&gt;Message&lt;\/label&gt; &lt;textarea name=\"message\" value={formData.message} onChange={handleChange} className=\"form-input\" rows=\"6\" required &gt;&lt;\/textarea&gt; &lt;\/div&gt; &lt;\/&gt;\n);\n};\nexport default EmailFormFields;\n<\/code><\/pre>\n<h2>React JSX to load EmailJS and EmailFormFields Component<\/h2>\n<p>This JSX defines the <code>handleChange<\/code> and <code>handleSubmit<\/code> <a href=\"https:\/\/phppot.com\/react\/react-hook-user-registration-form\/\">hooks for validation<\/a> and mail sending respectively.<\/p>\n<p>The form container includes the <code>&lt;EmailFormFields \/&gt;<\/code>, Submit button and a <code>&lt;ToastContainer \/&gt;<\/code>.<\/p>\n<p>After sending email via emailjs, the handleSubmit action resets the form and make it ready for the next submit.<\/p>\n<p>When submitting the form, the <code>handleSubmit<\/code> function sends the formData with the API keys and IDs. Configure your EmailJS keys and IDs to this React script to make this example to send email.<\/p>\n<p class=\"code-heading\"><code>src\/components\/EmailForm.jsx<\/code><\/p>\n<pre class=\"prettyprint\"><code class=\"language-jsx\">import { useState } from \"react\";\nimport emailjs from \"emailjs-com\";\nimport { ToastContainer, toast } from \"react-toastify\";\nimport \"react-toastify\/dist\/ReactToastify.css\";\nimport \"..\/..\/public\/assets\/css\/phppot-style.css\";\nimport EmailFormFields from \".\/EmailFormFields\"; const EmailForm = () =&gt; { const [formData, setFormData] = useState({ name: \"\", email: \"\", message: \"\", }); const handleChange = (e) =&gt; { const { name, value } = e.target; setFormData((prev) =&gt; ({ ...prev, [name]: value })); }; const handleSubmit = (e) =&gt; { e.preventDefault(); const SERVICE_ID = \"Your Serivce ID\"; const TEMPLATE_ID = \"Your Template ID\"; const PUBLIC_KEY = \"EmailJS API Public key here\"; emailjs .send(SERVICE_ID, TEMPLATE_ID, formData, PUBLIC_KEY) .then(() =&gt; { toast.success(\"Email sent successfully!\", { position: \"top-center\" }); setFormData({ name: \"\", email: \"\", message: \"\" }); }) .catch(() =&gt; { toast.error(\"Failed to send email. Please try again.\", { position: \"top-center\", }); }); }; return ( &lt;div className=\"form-wrapper\"&gt; &lt;h2 className=\"form-title\"&gt;Contact Us&lt;\/h2&gt; &lt;form onSubmit={handleSubmit} className=\"payment-form\"&gt; &lt;EmailFormFields formData={formData} handleChange={handleChange} \/&gt; &lt;button type=\"submit\" className=\"submit-btn\"&gt; Send &lt;\/button&gt; &lt;\/form&gt; &lt;ToastContainer \/&gt; &lt;\/div&gt; );\n};\nexport default EmailForm;\n<\/code><\/pre>\n<p><strong>Note: <\/strong>Form data is in an associate array format, where the array keys matches the email template variables. For example, if the email template body in the EmailJS dashboard contains <code>Hi {{name}}<\/code>, then the form data will have the key-value as <code>name: submitted-name<\/code> to replace the variable.<\/p>\n<p>The receive email signature and the mail body design will be as configured in the EmailJS dashboard. The following diagram shows the received email output.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-24640\" src=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-received-web-mail-1-550x309.jpg\" alt=\"React Received Web Mail\" width=\"550\" height=\"309\" srcset=\"https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-received-web-mail-1-550x309.jpg 550w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-received-web-mail-1-300x168.jpg 300w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-received-web-mail-1-768x431.jpg 768w, https:\/\/phppot.com\/wp-content\/uploads\/2025\/11\/react-received-web-mail-1.jpg 1499w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\"><\/p>\n<h2>Conclusion<\/h2>\n<p>Thus, we have created a frontend in React for sending email without any backend set up. I hope, you find EmailJS very simple to integrate into an application. And its registration process is very simple. And, the features to customize the email body is very useful to have a thematic email template for different applications.<\/p>\n<p><a class=\"download\" href=\"https:\/\/phppot.com\/downloads\/react\/send-email-from-react-using-emailjs.zip\">Download<\/a><\/p>\n<div class=\"written-by\" readability=\"9.8427672955975\">\n<div class=\"author-photo\"> <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/phppot.com\/wp-content\/themes\/solandra\/images\/Vincy.jpg\" alt=\"Vincy\" width=\"100\" height=\"100\" title=\"Vincy\"> <\/div>\n<div class=\"written-by-desc\" readability=\"14.764150943396\"> Written by <a href=\"https:\/\/phppot.com\/about\/\">Vincy<\/a>, a web developer with 15+ years of experience and a Masters degree in Computer Science. She specializes in building modern, lightweight websites using PHP, JavaScript, React, and related technologies. Phppot helps you in mastering web development through over a decade of publishing quality tutorials. <\/div>\n<\/p><\/div>\n<p> <!-- #comments --> <\/p>\n<div class=\"related-articles\">\n<h2>Related Tutorials<\/h2>\n<\/p><\/div>\n<p> <a href=\"https:\/\/phppot.com\/react\/send-email-from-react-using-emailjs\/#top\" class=\"top\">\u2191 Back to Top<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>by Vincy. Last modified on November 13th, 2025. EmailJS is a cloud service that supports to enable the frontend to send email without any backend. All we need is to create an EmailJS account and configure it to the frontend application. This tutorial shows the step-by-step procedure to learn how to enable email sending in [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":135321,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[],"class_list":["post-135320","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-updates"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/135320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=135320"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/135320\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media\/135321"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=135320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=135320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=135320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}