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

@warren-bank/email-relay

v1.0.1

Published

SMTP proxy server with middleware capability.

Downloads

8

Readme

email-relay

SMTP proxy server with middleware capability.

Installation:

npm install --global @warren-bank/email-relay

Usage:

email-relay <options>

options:
========
"-H"
"--help"
    Print a help message describing all command-line options.

"-V"
"--version"
    Display the version.

"-D"
"--debug"
    Boolean flag to enable printing of debug logs
    for all messages received by the local SMTP server,
    and to disable their forwarding to the remote SMTP server.

"-lp" <number>
"--local-port" <number>
    Specify the port number that the local SMTP server listens on.
    [Default: 25]

"-h" <hostname>
"--remote-host" <hostname>
    Specify the hostname of the remote SMTP server.
    [Required]

"-rp" <number>
"--remote-port" <number>
    Specify the port number of the remote SMTP server.
    [Default: 25]

"-s"
"--remote-secure"
    Boolean flag to indicate that the remote SMTP server uses a secure (TLS or SSL) connection.
    [Default: false]

"-u" <username>
"--remote-username" <username>
    Specify the username for account authentication on the remote SMTP server.
    [Optional]

"-p" <password>
"--remote-password" <password>
    Specify the password for account authentication on the remote SMTP server.
    [Optional]

"-f" <email-address>
"--send-email-from" <email-address>
    Specify an email address to override the "from" sender
    for all messages received by the local SMTP server,
    before they are forwarded to the remote SMTP server.
    [Optional]

"-m" </path/to/file.js>
"--middleware" </path/to/file.js>
    Specifies the absolute filepath to a CommonJS module that exports a single function.
    This function can be used to conditionally modify any attribute
    of all messages received by the local SMTP server,
    before they are forwarded to the remote SMTP server.
    [Optional. Can be used more than once.]

"-LTT1"
"--legacy-tls-tweak-01"
    Boolean flag to enable the addition of a configuration tweak
    that may be required to support a secure connection to the remote SMTP server
    when either the local client (version of Node) or remote server only supports legacy protocols.
    This configuration tweak is:
      options.tls.ciphers = 'SSLv3'

"-LTT2"
"--legacy-tls-tweak-02"
    Boolean flag to enable the addition of a configuration tweak
    that may be required to support a secure connection to the remote SMTP server
    when either the local client (version of Node) or remote server only supports legacy protocols.
    This configuration tweak is:
      options.tls.minVersion = 'TLSv1'

"-LTT3"
"--legacy-tls-tweak-03"
    Boolean flag to enable the addition of a configuration tweak
    that may be required to support a secure connection to the remote SMTP server
    when either the local client (version of Node) or remote server only supports legacy protocols.
    This configuration tweak is:
      options.tls.rejectUnauthorized = false

Middleware:

  • each middleware function is synchronously processed in the order given on the command-line
  • the same message configuration object is passed as an input parameter to each middleware function
  • this object is passed by reference, and its attributes can be directly modified

Running Locally for Testing:

  • download and unzip into any local directory
  • open terminal and change directory to where the repo snapshot was unzipped:
      cd /path/to/node-email-relay-master
  • install dependencies:
      npm install
  • start server in debug mode and pipe output to a log file:
      npm start -- -D >debug.log 2>&1
  • test server by sending a message to it:
      npm run "tests:01"
  • inspect the debug log:
      cat debug.log

Troubleshooting:

  • a secure (TLS or SSL) connection to the remote SMTP server
    • nodemailer documentation says that:
      • the --remote-secure option should only be used with --remote-port 465. for all other port numbers, the connection will upgrade to use TLS if the remote server supports it.
      • the -LTT3 option is applicable when using an older version of Node, that does not fully support the certificate chain of the newest Let's Encrypt certificates.
      • the -LTT2 option is applicable when connecting to a remote SMTP server that only supports TLS v1.1 or lower. relevant Node documentation:
    • nodemailer issue 165 says that:
      • the -LTT1 option is applicable when connecting to a remote SMTP server that only supports SSL v3. relevant Node documentation:

Real-World Example for Yahoo Mail:

  • documentation for connecting to remote SMTP server: | | | |----------|---------------------------| | hostname | smtp.mail.yahoo.com | | port | 465 (SSL) or 587 (SSL) | | secure | true | | username | [email protected] | | password | my-generated-app-password |
  • account page to generate a Yahoo Mail app password:
    • Account Security > Generate app password
  • <options>:
      my_email='[email protected]'
      my_password='0123456789abcdef'
    
      email-relay -h "smtp.mail.yahoo.com" -rp "465" -s -u "$my_email" -p "$my_password" -f "$my_email"

Real-World Example for GMX Mail:

  • documentation for connecting to remote SMTP server: | | | |----------|--------------------------------------------------| | hostname | mail.gmx.com | | port | 465 (SSL or TLS) or 587 (STARTTLS or encryption) | | secure | false or true | | username | [email protected] | | password | my-website-login-password |
  • <options>:
      my_email='[email protected]'
      my_password='my-website-login-password'
    
      email-relay -h "mail.gmx.com" -rp "465" -s -u "$my_email" -p "$my_password" -f "$my_email"

Real-World Example for Zoho Mail:

  • documentation for connecting to remote SMTP server: | | | |----------|---------------------------| | hostname | smtp.zoho.com | | port | 465 (SSL) or 587 (TLS) | | secure | true | | username | [email protected] | | password | my-website-login-password |
  • <options>:
      my_email='[email protected]'
      my_password='my-website-login-password'
    
      email-relay -h "smtp.zoho.com" -rp "465" -s -u "$my_email" -p "$my_password" -f "$my_email"

Etc:

The following command-line SMTP clients are worthy of a mention. They provide an easy way to send messages to a running instance of email-relay.

  1. blat
    • platforms: Windows
    • example of usage:
        rem :: a value for the "from" sender is required,
        rem :: but "email-relay" is configured to override this value.
        set [email protected]
      
        set [email protected]
        set subject=Test: blat
        set body=Hello, SMTPd!
        set smtpd_host=localhost
        set smtpd_port=25
      
        blat.exe -f "%email_from%" -to "%email_to%" -subject "%subject%" -body "%body%" -server "%smtpd_host%:%smtpd_port%"
    • tested with: v3.22.4 for Win64
  2. mailsend-go
    • platforms: Windows, Linux, MacOS, Raspberry pi
    • example of usage:
        rem :: a value for the "from" sender is required,
        rem :: but "email-relay" is configured to override this value.
        set [email protected]
      
        set [email protected]
        set subject=Test: mailsend-go
        set body=Hello, SMTPd!
        set smtpd_host=localhost
        set smtpd_port=25
      
        mailsend-go.exe -f "%email_from%" -t "%email_to%" -sub "%subject%" body -msg "%body%" -smtp "%smtpd_host%" -port "%smtpd_port%"
    • tested with: v1.0.10 for Win64

Credits:

Nodemailer does absolutely all of the heavy lifting required by this project:

Legal: