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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sfn-mail

v0.2.1

Published

Simple Friendly Node.js Email client for sending messages.

Downloads

11

Readme

SFN-Mail

Simple Friendly Node.js Mail client for sending messages.

This package is a simple wrapper for Nodemailer.

Install

npm install sfn-email

Example

const Mail = require("sfn-email");

Mail.init({
    host: "smtp.mail.qq.com",
    port: 25,
    from: "[email protected]",
    auth: {
        username: "[email protected]",
        password: "xxxxxxxx",
    }
});

(async() => {
    var mail = new Mail("A test email");
    mail.to("[email protected]")
        .text("Text content");
    try {
        var res = await mail.send();
        console.log(res);
    } catch (e) {
        console.log(e);
    }
    console.log(mail);
})();

API

  • Mail.init(options: object) Initiates email transport configurations.
    • options Transport configurations for Nodemailer, may carry a from property sets the default from address. Other options, please check https://nodemailer.com/smtp/.
  • new Mail(options: object)
  • new Mail(subject: string, options?: object) Creates a new email with a specified subject.
    • subject Email subject, optionally you can ignore this argument, just set the options, and set the subject in the options.
    • options Transport configurations for Nodemailer, may carry a from property sets the from address, and a to property sets a receiver or receivers, and an optional subject if you don't pass it as an argument.
  • mail.from(address: string) Sets the sender address.
  • mail.to(...address: string[]) Sets receiver addresses, optionally you can call this method multiple times to concatenate addresses.
  • mail.cc(...address: string[]) Sets receiver addresses on the CC field, optionally you can call this method multiple times to concatenate addresses.
  • mail.cc(...address: string[]) Sets receiver addresses on the BCC field, optionally you can call this method multiple times to concatenate addresses.
  • mail.text(content: string) Sets the plain text version of the email.
  • mail.html(content: string) Sets the HTML version of the email.
  • mail.attchment(filename: string) Sets a file as an attachment sent with the email, optionally you can call this method multiple times to attach multiple files.
  • mail.header(field: string, value: string | number | Date) Sets a header field sent with the email, optionally you can call this method multiple times to set multiple fields.
  • mail.send(): Promise Sends the email to all recipients. Returns a Promise, the only argument passed to the callback of then() is an object which may carry information like:
    • messageId the final Message-Id value;
    • envelope the envelope object for the message;
    • accepted recipient addresses that were accepted by the server;
    • rejected recipient addresses that were rejected by the server;
    • pending recipient addresses that were temporarily rejected; together with the server response;
    • response the last SMTP response from the server.