Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smtp-client-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smtp-client-ts

A SMTP Client in TypeScript

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

TypeScript SMTP Client

Author: Jonathan M. Wilbur <jonathan@wilbur.space> Copyright Year: 2019 License: MIT License

Usage

import { Client } from "../source/Client";
import { Response } from "../source/Response";

// I am using port 26 here, because my ISP blocks ports 25.
// I specifically added a listener on port 26 on my email server for the
// purposes of testing this.
const client : Client = new Client("email.wilbur.space", 26);
(async () => {
    const connectResponse : Response = await client.connect();
    console.log(`${connectResponse.code} ${connectResponse.lines.toString()}`);

    const ehloResponse : Response = await client.ehlo("bigboiiii.com");
    console.log(`${ehloResponse.code} ${ehloResponse.lines.map((line) => line.toString()).join("\r\n")}`);

    console.log("MAIL");
    const mailResponse : Response = await client.mail("bigboi@wuuut.com");
    console.log(`${mailResponse.code} ${mailResponse.lines.toString()}`);

    console.log("RCPT");
    const rcptResponse : Response = await client.rcpt("jonathan@wilbur.space");
    console.log(`${rcptResponse.code} ${rcptResponse.lines.toString()}`);

    console.log("DATA");
    const dataResponse : Response = await client.data();
    console.log(`${dataResponse.code} ${dataResponse.lines.toString()}`);

    console.log("writing data...");
    const writeResponse : Response = await client.writeData("WHO WANTS A BODY MASSAGE?");
    console.log(`${writeResponse.code} ${writeResponse.lines.toString()}`);

    console.log("QUIT");
    const quitResponse : Response = await client.quit();
    console.log(`${quitResponse.code} ${quitResponse.lines.toString()}`);

})();

Notes

For testing, I had to change my test email server to listen on port 26, because my ISP blocks outbound port 25 traffic.

In my testing, it appears that the RCPT command hangs for tens of seconds. This might only be specific to my testing environment, which was testing against Postfix via plaintext SMTP on port 26 (not a typo).

FAQs

Package last updated on 14 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc