This is an example of how to use the nodemailer
module to send an email using Node.js.
- Install the
nodemailer
module by runningnpm install nodemailer
. - In the
transfer
object, enter your Gmail email address and password in theuser
andpass
fields respectively. - In the
mailinfo
object, enter the sender's email address in thefrom
field, the recipient's email address in theto
field, the subject of the email in thesubject
field, and the plain text content of the email in thetext
field.
Run the script using node <script_name>.js
. If successful, you should see a "Mail Sended" message in the console.
- You can uncomment the
html
field in themailinfo
object to include HTML content in the email. - Make sure to allow less secure apps to access your Gmail account. You can do this by going to your Google account settings and enabling "Less secure app access".