Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to send email

import React, { useRef } from "react";
import emailjs from "@emailjs/browser";

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

  const num =(Math.floor(Math.random() * 1000));

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

    emailjs
      .sendForm("gmail", "test-temp", e.target, "v8vKjhc4544PvRhT-")
      .then(
        (result) => {
          console.log(result);
        },
        (error) => {
          console.log(error.text);
        }
      );

    e.target.reset();
  };

  return (
    <form ref={form} onSubmit={sendEmail}>
      <label>Subject</label>
      <input type="text" name="subject" />

      <label>Name</label>
      <input type="text" name="name" />

      <label>Email</label>
      <input type="email" name="email" />

      <label>Send to</label>
      <input type="email" name="to_email" />

      <label>Message</label>
      <textarea name="message" />

      <input name="randomNum" defaultValue={num}/>

      <input type="submit" value="Send" />
    </form>
  );
};

export default ContactUs;
Comment

PREVIOUS NEXT
Code Example
Javascript :: take money from user and give change as output using javascript 
Javascript :: How display console log in frontend 
Javascript :: js react change slide by touch event 
Javascript :: Your task is to take every letter and its index and form a string out of them. javascript 
Javascript :: foreach doesnt return 
Javascript :: how to merge data react native 
Javascript :: implict type coercion in js 
Javascript :: discord.js permission bitfield 
Javascript :: react computed hook 
Javascript :: jquery redirect to another page on radio button 
Javascript :: wakatime cli installation via npm 
Javascript :: material ui paper color default background 
Javascript :: my code agly because alot of if and else dev community 
Javascript :: Private slots are new and can be created via Static initialisation blocks in classes 
Javascript :: recharts area chart 
Javascript :: typeorm with better sqlite using query builder 
Javascript :: react app environment variables undefined even when starts with REACT_APP_ 
Javascript :: js set array relation 
Javascript :: What is the time complexity of fun()? int fun(int n) { int count = 0; for (int i = 0; i < n; i++) for (int j = i; j 0; j--) count = count + 1; return count; } 
Javascript :: Using toLocaleString() to Print JavaScript Number Format with Commas 
Javascript :: Constant declaration in ES6 
Javascript :: what does react js allows us to do 
Javascript :: find a node that match a spesific selector string in the paren 
Javascript :: angular cache interceptor 
Javascript :: reuse jquery angular 
Javascript :: fs keep file open 
Javascript :: use this in a react js component 
Javascript :: splinter wait for input 
Javascript :: get call log in react native android 
Javascript :: angular 10 filter date time 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =