Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

nodemailer 6.9.9

Easy as cake e-mail sending from your Node.js applications
Package summary
Share
0
issues
0
licenses
Package created
21 Jan 2011
Version published
1 Feb 2024
Maintainers
1
Total deps
0
Direct deps
0
License
MIT-0
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does nodemailer do?

Nodemailer is a popular npm package that allows for simple email sending from your Node.js applications. Essentially, it's your go-to module for programmatically sending emails right from a Node.js server. It's just as easy as baking a cake! πŸ°βœ‰οΈ

How do you use nodemailer?

Using Nodemailer requires initialization and setup of a transport object. This transport object defines the method of sending emails from your Node.js server, usually using an SMTP server. Here's a basic usage example:

const nodemailer = require('nodemailer');

let transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
        user: 'example@gmail.com',
        pass: 'password'
    }
});

let mailOptions = {
    from: 'example@gmail.com',
    to: 'receiver@example.com',
    subject: 'Test email',
    text: 'Hello World!'
};

transporter.sendMail(mailOptions, function(err, info){
    if (err) {
        console.log(err);
    } else {
        console.log('Email sent successfully: ' + info.response);
    }
});

In this example, we're using Gmail as the email service. First, we import the Nodemailer module, then create a transporter object with the Gmail service and authentication details. We then define our mail options, which identify the sender, receiver, subject, and the body (text) of the email. Lastly, we use the sendMail method of the transporter object to send the email, providing feedback via the console on whether the email was successfully sent.

Where are the nodemailer docs?

Nodemailer provides extensive documentation and examples to support its usage in a multitude of scenarios. Visit Nodemailer's website for a complete guide, troubleshooting tips, and more on how to optimally integrate it into your Node.js application.