npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hospitaria-graph-mailer

v1.0.2

Published

Cliente reutilizable para envio de correo mediante Microsoft Graph.

Readme

hospitaria-graph-mailer

Cliente reutilizable para enviar correos por Microsoft Graph desde Node.js.

Instalacion

npm install hospitaria-graph-mailer

Requisitos

  • Node.js 18 o superior
  • Una app de Azure AD con permisos para enviar correo por Microsoft Graph

Variables de entorno sugeridas:

TENANT=tu-tenant-id
MICROSOFT_CLIENT_ID_SEND_EMAIL=tu-client-id
MICROSOFT_SECRET_ID_SEND_EMAIL=tu-client-secret
[email protected]

Uso basico

const { createMailerFromEnv } = require("hospitaria-graph-mailer");

const mailer = createMailerFromEnv();

await mailer.send({
    from: "[email protected]",
    to: ["[email protected]"],
    cc: ["[email protected]"],
    bcc: ["[email protected]"],
    subject: "Orden de compra",
    html: "<h1>Hola</h1><p>Adjunto encontraras el pdf.</p>",
    attachments: [
        {
            filename: "orden_123.pdf",
            content: pdfBuffer,
            contentType: "application/pdf",
        },
    ],
    saveToSentItems: true,
});

Uso manual

const { GraphMailer } = require("hospitaria-graph-mailer");

const mailer = new GraphMailer({
    tenantId: process.env.TENANT,
    clientId: process.env.MICROSOFT_CLIENT_ID_SEND_EMAIL,
    clientSecret: process.env.MICROSOFT_SECRET_ID_SEND_EMAIL,
    defaultFrom: process.env.GRAPH_MAILER_DEFAULT_FROM,
});

API

new GraphMailer(options)

Opciones:

  • tenantId: tenant de Azure AD
  • clientId: client id de la app
  • clientSecret: client secret de la app
  • defaultFrom: correo remitente por default

createMailerFromEnv(options)

Crea una instancia de GraphMailer leyendo credenciales desde variables de entorno.

Campos soportados:

  • env: objeto origen de variables de entorno, process.env por default
  • tenantIdKey: nombre de la variable para el tenant, TENANT por default
  • clientIdKey: nombre de la variable para el client id, MICROSOFT_CLIENT_ID_SEND_EMAIL por default
  • clientSecretKey: nombre de la variable para el client secret, MICROSOFT_SECRET_ID_SEND_EMAIL por default
  • defaultFromKey: nombre de la variable para defaultFrom, GRAPH_MAILER_DEFAULT_FROM por default
  • defaultFrom: fallback manual si no existe defaultFromKey

Ejemplo:

const { createMailerFromEnv } = require("hospitaria-graph-mailer");

const mailer = createMailerFromEnv({
    env: process.env, // opcional
    tenantIdKey: "TENANT", // opcional
    clientIdKey: "MICROSOFT_CLIENT_ID_SEND_EMAIL", // opcional
    clientSecretKey: "MICROSOFT_SECRET_ID_SEND_EMAIL", // opcional
    defaultFromKey: "GRAPH_MAILER_DEFAULT_FROM", // opcional
    defaultFrom: "[email protected]", // opcional
});

mailer.send(message)

Campos soportados:

  • from: remitente para este envio
  • to: arreglo de correos destino
  • cc: arreglo de correos copia
  • bcc: arreglo de correos copia oculta
  • subject: asunto
  • html: cuerpo HTML
  • attachments: arreglo de adjuntos
  • saveToSentItems: true por default

Adjuntos:

{
  filename: "archivo.pdf",
  content: bufferODatoString,
  contentType: "application/pdf",
  encoding: "utf8" // opcional; usa "base64" si content ya viene codificado
}

Helper HTML

const {
    buildEmailLayout,
    buildHtmlTable,
} = require("hospitaria-graph-mailer");

const table = buildHtmlTable(
    [
        { Cuenta: 1001, Paciente: "Juan Perez" },
        { Cuenta: 1002, Paciente: "Maria Lopez" },
    ],
    { title: "Cargos aplicados" }
);

const html = buildEmailLayout(table, {
    title: "Reporte de cargos",
    subtitle: "Resumen del corte del dia",
    logoUrl: "https://midominio.com/logo-hospitaria.png",
    logoAlt: "Hospitaria",
    footer: "Este correo fue generado automaticamente por Hospitaria.",
    preheader: "Tu reporte diario ya esta listo",
});

Tambien puedes usarlo sin content si solo quieres un encabezado visual:

const { buildEmailLayout } = require("hospitaria-graph-mailer");

const html = buildEmailLayout(undefined, {
    title: "Proceso finalizado",
    subtitle: "La carga termino correctamente",
    logoUrl: "https://midominio.com/logo-hospitaria.png",
    footer: "Mensaje generado automaticamente.",
});

buildEmailLayout(content, options)

Construye un documento HTML base para correo y permite insertar contenido ya renderizado.

Campos soportados:

  • content: HTML principal del correo, opcional
  • title: titulo principal
  • subtitle: texto secundario bajo el titulo
  • logoUrl: URL publica del logo a mostrar arriba del encabezado
  • logoAlt: texto alternativo del logo, Logo por default
  • logoWidth: ancho del logo en pixeles como string, 160 por default
  • footer: texto de cierre
  • preheader: texto oculto para clientes de correo
  • lang: atributo lang del documento, es por default
  • maxWidth: ancho maximo del contenedor, 640px por default
  • accentColor: color de acento del encabezado
  • backgroundColor: color de fondo exterior
  • cardColor: color del contenedor principal
  • bodyColor: color base del texto