Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

emailjs react npm

//npm install @emailjs/browser
import React, { useRef } from 'react';
import emailjs from '@emailjs/browser';

export const ContactUs = () => {
  const form = useRef();

  const sendEmail = (e) => {
    e.preventDefault();

    emailjs.sendForm('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', form.current, 'YOUR_USER_ID')
      .then((result) => {
          console.log(result.text);
      }, (error) => {
          console.log(error.text);
      });
  };

  return (
    <form ref={form} onSubmit={sendEmail}>
      <label>Name</label>
      <input type="text" name="user_name" />
      <label>Email</label>
      <input type="email" name="user_email" />
      <label>Message</label>
      <textarea name="message" />
      <input type="submit" value="Send" />
    </form>
  );
};

// seee doc for more info, https://www.emailjs.com/docs/examples/reactjs/
Comment

PREVIOUS NEXT
Code Example
Javascript :: input type number maxlength in react 
Javascript :: add days in mome 
Javascript :: google auth.onstatechange 
Javascript :: javascript 1 line if 
Javascript :: percentage formula in javascript 
Javascript :: how to capitalize first letter in javascript 
Javascript :: on() jquery 
Javascript :: nodejs import instead of require 
Javascript :: Map in Javascript in LWC 
Javascript :: document get elements by id js 
Javascript :: on refresh react url not working or 404 page not showing react 
Javascript :: delete node module 
Javascript :: binarycent login 
Javascript :: JavaScript Object Constructors 
Javascript :: random coordinates js 
Javascript :: date now js 
Javascript :: regex for comments javascript 
Javascript :: To get thumbnail image from video file 
Javascript :: node js return ID in postgres insert 
Javascript :: how do i check if JQuery checkbox is checked 
Javascript :: check how many files in a folder js 
Javascript :: downgrade nodejs with nvm 
Javascript :: js sum of int in array 
Javascript :: get count of class which is visible element 
Javascript :: js how to find element using id 
Javascript :: javascript click counter 
Javascript :: jquery set select value 
Javascript :: change key name in array of objects javascript 
Javascript :: nodejs redis setex 
Javascript :: window load 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =