Code Monkey home page Code Monkey logo

emailjs-youtube-tutorial's Introduction

EmailJs-Youtube-Tutorial

Link to video: https://www.youtube.com/watch?v=NgWGllOjkbs&feature=youtu.be

There are multiple methods to getting emails to send through React. You can use Nodemailer, use express backend methods and so many others.

We are going to be using EmailJs!

This does not include saving information via form to your backend

Service we are using: https://www.emailjs.com/

Step 1: Go to https://www.emailjs.com/ and create a free account.

Step 2: Once you have created an account you will need to connect your email service. I have only used Gmail and I have only tested using gmail.

Step 3: Now you will want to click "Email Templates" on the left side and then click "Create new template". After formatting your template be sure to enter your email on the right side under "To email". Click Test if you want to send a test email or click save.

Step 4: Go back to https://www.emailjs.com/ and click docs at the top

Step 5: After clicking docs scroll down to "Examples" and click React

Step 6: Lines of code to copy are...
1. import emailjs from "emailjs-com";
2. 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);
});
}

Step 7. We need to fill out the 3 of 4 parameters after sendForm. Pro-tip if you hover over sendForm in your code editor it will tell you what they paramerters mean.
1. "YOUR_SERVICE_ID" this is the type of email server you are using
2. "YOUR_TEMPLATE_ID" this is the templateID when you create a template within the EmailJs website.
3. e.target is related to what the user is typing through your form, leave this one alone.
4. "YOUR_USER_ID" is your API Key to get to this you need to click on your name in the top right, in my instance it was "Michael Remy" after clicking your name you will then click on "API KEYS" then you want to copy your User ID:

Step 8. That's it! If you created your React form correctly and you are calling the function "sendEmail" on your form onSubmit then your templated email should be sent to you!

I hope you find this very helpful in being able to send emails to yourself through React.\

emailjs-youtube-tutorial's People

Contributors

michaeldremy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.