> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailofly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Nodemailer

# Sending with Nodemailer

Integrate Mailofly into your Node.js application using the popular `nodemailer` library.

***

## Installation

```bash theme={null}
npm install nodemailer
npm install -D @types/nodemailer
```

***

## Example

```typescript theme={null}
import nodemailer from "nodemailer";

const transporter = nodemailer.createTransport({
  host: "smtp.mailofly.com",
  port: 587,
  secure: false, // true for 465, false for other ports
  auth: {
    user: "mailofly",
    pass: process.env.MAILOFLY_API_KEY, // e.g. mfly_live_...
  },
});

async function main() {
  const info = await transporter.sendMail({
    from: '"Acme" <alerts@yourcompany.com>',
    to: "alex@example.com",
    subject: "Hello via Nodemailer & Mailofly",
    text: "Plaintext fallback message",
    html: "<b>Hello from Mailofly SMTP!</b>",
  });

  console.log("Message sent: %s", info.messageId);
}

main().catch(console.error);
```


## Related topics

- [Introduction](/smtp/introduction.md)
- [Integrations](/integrations/index.md)
- [Supabase](/smtp/supabase.md)
- [Laravel](/smtp/laravel.md)
