Search code examples
node.jsgmail-apinodemailer

How to send email using gmail in nodejs in 2023?


I need to send email from my server side which is node js. I browse about how to send email with gmail in node js but all were outdated. Google deactivated the less secure app feature last year.

Then I found gmail API. I tried browse again about how send email with gmail api but I didnt find anything useful. Tried to read the gmail API docs but they dont give example for nodejs( only java and python). So can anyone tell me the latest method( 2023 method) about how to send email with gmail API? Or at least give me a reference.


Solution

  • For sending email in nodejs you can use Nodemailer library..

    Here is the link to documentation of library:https://nodemailer.com/about/

    For SMTP Configurations you can refer to the following site:https://www.lifewire.com/what-are-the-gmail-smtp-settings-1170854

    Note:Generate app password from the mail account through which you want to send emails..normal password doesn't works here..

    Here is the link how you can generate app password: https://support.google.com/mail/answer/185833?hl=en