How to Send Emails with Node.js and Nodemailer - Tutorial by Mailtrap

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello there in this video we shall cover how to send emails with node mailer using three different methods a regular SMTP server the official mailtrap node.js client and how to send emails via gmailismtp server if you would like to jump to one of these parts right away feel free to use the timestamps available below now welcome to mailtrap videos where we share email deliverability tips here's how to send emails with node mailer first let's take a look at sending messages using SMTP as a basis for the example I'll take the node mailer documentation so first we need to install node meter then you need to add the required and the rest of the necessary elements all in all our code is almost ready and what's left is to replace the configuration with the one we need in this example I'll be using mailtrap's SMTP settings let's copy the domain name leave the port as it is add your username and your password and that's it now let's replace the sender's email for the recipient's email I'm using an example address I prepared in advance let's set the subject of the email add some text in the body of the email we can get rid of the HTML Parts since we don't really need it in this example now make sure to save the file and we're done now let's run the script as we can see in the logs the message was sent let's make sure that it was delivered and there it is we have just learned one method out of three and there's more to go so keep on watching by the way all the details are covered in our article plus we have all the relevant code on our GitHub page you can find the links for both of these in the video description below now before we jump into the next two methods if you are finding this video useful do give it a thumbs up this way you are helping YouTube to spread the knowledge and more viewers can benefit from content like this now let us take a look at how we can send emails using the official mailtrap node.js client now this one is super convenient as the email delivery platform mail trap itself allows you to test send and control all of your email infrastructure performance in one place so you can just set up everything and forget about it while it does the job and delivers the emails for you here's how it works with node.js so for the sake of this example I'll use the simple scenario listed in the minimal section of the GitHub page let's start by installing the required package after that let's import the library next configure the client and in this case I slightly modified the code for this example and my version ended up looking like this now let's fill in the required Fields first we do the token one which is the password for your mailtrap account next let's fill in the sender's email address keep in mind that it's important to use the correct domain from which the emails will be sent otherwise it will not pass the validation now let's indicate the receiver's email and the subject add some text on the body of the email and that's it we are ready to run our script the script ran successfully and we can see that the email was indeed delivered laws but definitely not least let us take a look at how we can send emails with node mailer using Gmail SMTP the most straightforward option for sending emails with Gmail SMTP is to use the app password this is a 16 digit passcode that gives a less secure app or device permission to access your Google account you can create the passcode in the add password section of your Google account our article also has a solid description of this process for this example I already prepare per VR password so first let's install nodemeeler next you want to copy and paste the transporter configuration which can be found in our article also remember to add the require and now add the actual code to send the email message you can find this code in the article too after this let's specify the required settings user which is your Gmail email address pass which is the add password you generated now indicate the from and two email addresses to keep things simple I'm using the same email address for both but of course you can specify any other actual email addresses but save this and run our script and from the logs we can see that the email went through now let's see if it was delivered to the inbox and yep it was just like that you know JSF can quickly start sending emails again all of the links of articles that I mentioned and the GitHub page are available in the description below we at mailtrap do hope you found this tutorial helpful and for your convenience you can simply copy the pieces of the code right from the article I will make sure to link everything in the video description below so that you can have it for any future users do let us know which sending method do you prefer and why we would love to chat with you in the comments thank you for watching this video brought to you by mailtrap an email delivery platform for individuals and businesses to test send and control all of your email infrastructure in one place like and share this video And subscribe to our channel to see more tutorials like this one as well as check out our other videos for more useful content on email deliverability and I will see you soon in our next one
Info
Channel: Mailtrap
Views: 11,081
Rating: undefined out of 5
Keywords: Mailtrap, Email delivery platform, email deliverability, email api, smtp, transactional emails, email platform, how to send transactional emails, send emails code tutorial, emails, nodejs, nodemailer, send emails with nodejs, receive emails with nodejs, send emails with nodemailer, receive emails with nodemailer, nodejs send email smtp, send mail node js, send mail using node js example, node js, node js email client, node js gmail, node email, node email template, mailtrap.io
Id: Wa9KDiB7C_I
Channel Id: undefined
Length: 4min 52sec (292 seconds)
Published: Wed Mar 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.