Socket
Socket
Sign inDemoInstall

smtp-client-ts

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    smtp-client-ts

A SMTP Client in TypeScript


Version published
Weekly downloads
3
Maintainers
1
Install size
20.7 kB
Created
Weekly downloads
 

Readme

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

Last updated on 14 Mar 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc