nodemailer-fetch is a focused utility library designed to efficiently fetch HTTP URL contents. While primarily created to complement the Nodemailer ecosystem by providing a mechanism to retrieve remote content for email templates or attachments, it serves as a standalone HTTP client for general-purpose requests. The current stable version is 2.1.0. It generally follows a stable, on-demand release cadence typical for a mature utility module. Its key differentiators include robust handling of redirects (up to 5 by default), automatic gzip decompression, comprehensive cookie management with domain specificity, and built-in support for basic authentication, though with a notable caveat regarding redirects. It offers configurable TLS options and allows for custom HTTP methods (GET, POST), headers, and request bodies, making it flexible for various data fetching scenarios.
npm install nodemailer-fetchVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic HTTP GET and more complex POST requests, including piping the response, handling custom headers, body serialization, and setting timeouts.
Ensure the initial URL does not redirect, or handle authentication for redirected requests manually if the server supports session-based authentication.
Be mindful of cookie attributes (domain, secure flag) when dealing with redirects or mixed HTTP/HTTPS content. If cookies are critical across domains, consider alternative session management or re-sending them explicitly.
Set the `tls` option with appropriate `rejectUnauthorized: true` (or similar) settings to enforce stricter SSL validation, especially for sensitive data or production usage. Consult Node.js TLS documentation for detailed options.
Change your import statement from `import fetch from 'nodemailer-fetch';` to `const fetch = require('nodemailer-fetch');`. If your project is ESM-only, you might need to use dynamic `import('nodemailer-fetch')` or reconfigure your build system to handle CJS modules.Increase the `timeout` option value (in milliseconds) if the server typically takes longer to respond, or check network connectivity and firewall settings between your application and the target server.
If you expect and need to process non-successful HTTP responses, set the `allowErrorResponse: true` option in your fetch call. Otherwise, ensure the target URL and server logic are correct.
No dependency data recorded yet.