Send emails using React through EmailJs

Getting Started

<div className=”container”><div style={{ marginTop: “5%” }}><form><div class=”form-group”><label>Your Name</label><input name=”name” type=”text” class=”form-control”     placeholder=”Enter Your Name” /></div><div class=”form-group”><label>Email address</label><input name=”email” type=”email” class=”form-control” placeholder=”Enter Your Email” /></div><div class="form-group"><label>Message</label>

<textarea name="message" class="form-control" placeholder="Enter Your Message"></textarea>
</div><button type=”submit” class=”btn btn-primary”>Send Email</button></form></div></div>

EmailJS Integration

function sendEmail(e) {
e.preventDefault();
emailjs.sendForm('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', e.target, 'YOUR_USER_ID')
.then((result) => {
console.log(result.text);
}, (error) => {
console.log(error.text);
});
}

Testing

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Senura Vihan Jayadeva

Senura Vihan Jayadeva

93 Followers

Software Engineering undergraduate of Sri Lanka Institute of Information Technology | Physical Science Undergraduate of University of Sri Jayewardenepura