MailHog SMTP Protocol

Related tags

Email smtp
Overview

MailHog SMTP Protocol GoDoc Build Status

github.com/mailhog/smtp implements an SMTP server state machine.

It attempts to encapsulate as much of the SMTP protocol (plus its extensions) as possible without compromising configurability or requiring specific backend implementations.

proto := NewProtocol()
reply := proto.Start()
reply = proto.ProcessCommand("EHLO localhost")
// ...

See MailHog-Server and MailHog-MTA for example implementations.

Commands and replies

Interaction with the state machine is via:

  • the Parse function
  • the ProcessCommand and ProcessData functions

You can mix the use of all three functions as necessary.

Parse

Parse should be used on a raw text stream. It looks for an end of line (\r\n), and if found, processes a single command. Any unprocessed data is returned.

If any unprocessed data is returned, Parse should be called again to process then next command.

text := "EHLO localhost\r\nMAIL FROM:<test>\r\nDATA\r\nTest\r\n.\r\n"

var reply *smtp.Reply
for {
  text, reply = proto.Parse(text)
  if len(text) == 0 {
    break
  }
}

ProcessCommand and ProcessData

ProcessCommand should be used for an already parsed command (i.e., a complete SMTP "line" excluding the line ending).

ProcessData should be used if the protocol is in DATA state.

reply = proto.ProcessCommand("EHLO localhost")
reply = proto.ProcessCommand("MAIL FROM:<test>")
reply = proto.ProcessCommand("DATA")
reply = proto.ProcessData("Test\r\n.\r\n")

Hooks

The state machine provides hooks to manipulate its behaviour.

See GoDoc for more information.

Hook Description
LogHandler Called for every log message
MessageReceivedHandler Called for each message received
ValidateSenderHandler Called after MAIL FROM
ValidateRecipientHandler Called after RCPT TO
ValidateAuthenticationHandler Called after AUTH
SMTPVerbFilter Called for every SMTP command processed
TLSHandler Callback mashup called after STARTTLS
GetAuthenticationMechanismsHandler Called for each EHLO command

Behaviour flags

The state machine also exports variables to control its behaviour:

See GoDoc for more information.

Variable Description
RejectBrokenRCPTSyntax Reject non-conforming RCPT syntax
RejectBrokenMAILSyntax Reject non-conforming MAIL syntax
RequireTLS Require STARTTLS before other commands
MaximumRecipients Maximum recipients per message
MaximumLineLength Maximum length of SMTP line

Licence

Copyright ©‎ 2014-2015, Ian Kent (http://iankent.uk)

Released under MIT license, see LICENSE for details.

Issues
  • scripted telnet doesn't work

    scripted telnet doesn't work

    telnet 127.0.0.1 25 << EOF
    HELO cloudflare.com
    MAIL FROM:<[email protected]>
    RCPT TO:<[email protected]>
    DATA
    Body of email.
    .
    QUIT
    EOF
    

    I tested this with postfix and other mtas with no issues.

    opened by dknecht 1
  • support MAIL command with a null

    support MAIL command with a null

    MAIL command with a null is required in rfc5321 as shown below.

    https://tools.ietf.org/html/rfc5321#section-3.6.3

    One way to prevent loops in error reporting is to specify a null reverse-path
    in the MAIL command of a notification message.
    When such a message is transmitted, the reverse-path MUST be set to null
    (see   Section 4.5.5 for additional discussion).
    A MAIL command with a null reverse-path appears as follows:
    
      MAIL FROM:<>
    

    In fact, Postfix bounce emails have MAIL command set to "FROM:<>". But, MailHog validation judges "FROM:<>" as an error. Therefore, Postfix bounce email cannot be received by MailHog.

    This Pull Request allows you to receive Postfix bounce email by support MAIL command with a null.

    opened by stadaki 0
  • RSET clears EHLO

    RSET clears EHLO

    When issuing a RSET command, mailhog will reset the SMTPMessage. This will also clear the original Helo value. Since a "real" mail server will usually keep the smtp HELO value intact, would it be worthwhile to also have that behaviour here?

    https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L233

    opened by ernezt 1
  • Is this abandoned?

    Is this abandoned?

    I've had an open issue (#2), and two open PRs (#3, #4) for over a year, now, with no response here. Is there any hope the changes will ever be responded to?

    opened by dcormier 1
  • Hooks for SMTP extensions

    Hooks for SMTP extensions

    It would be really useful if SMTP extensions could be supported. This would include replying with the added SMTP extensions in the EHLO response, and providing hooks so extensions can add functionality.

    I'm attempting to support the SMTP Extensions for Internationalized Email (RFC 6531), but that's not possible with the current implementation.

    opened by dcormier 0
Owner
MailHog
Web and API based SMTP testing
MailHog
Lightweight SMTP client written in Go

Hectane Hectane is both a Go package providing an SMTP queue for sending emails and a standalone application that exposes this functionality via an HT

Hectane 221 Jun 18, 2022
Web and API based SMTP testing

MailHog Inspired by MailCatcher, easier to install. Download and run MailHog Configure your outgoing SMTP server View your outgoing email in a web UI

MailHog 10.3k Jun 23, 2022
:incoming_envelope: Simple email interface across multiple service providers (ses, postmark, mandrill, smtp)

go-mail Lightweight email package with multi-provider support (ses, mandrill, postmark) Table of Contents Installation Documentation Examples & Tests

MrZ 39 May 19, 2022
envio de email via SMTP com anexo usando Go

gosendmail - SMTP This repo is a simple net/smtp abstraction for sending emails using SMTP. With it we can send emails With copy, with blind copy and

Jefferson Otoni Lima 8 Dec 16, 2021
Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

Inbucket 1000 Jun 23, 2022
golang honeypot smtp server

honeygogo-smtp standalone honeypot A lightweight SMTP honeypot server written in Go, leveraging go-smtp. A stand alone version of a module from honeyg

jothflee 1 May 4, 2022
Simple SMTP Server for Testing

go-smtptester Simple SMTP Server for Testing. How it works All received mails are saved in a sync.Map with a key: From+Recipient1+Recipient2 Mails to

null 1 Nov 18, 2021
Simple tool to test SMTP mail send with various settings including TLS1.1 downgrade

smtptest Simple tool to test SMTP mail send with various settings including TLS1.1 downgrade All settings are configurable in the config.yaml file ser

Mario 0 Jan 6, 2022
Pretty wrapper for sending email using go net/smtp

Emailer A pretty wrapper around go net/smtp send multiple email using single client func main() { var client *emailer.Client var clientX sync.Mute

Vin. 1 Mar 23, 2022
Golang package for send email. Support keep alive connection, TLS and SSL. Easy for bulk SMTP.

Go Simple Mail The best way to send emails in Go with SMTP Keep Alive and Timeout for Connect and Send. IMPORTANT Examples in this README are for v2.2

Santiago De la Cruz 333 Jun 26, 2022
Lightweight SMTP client written in Go

Hectane Hectane is both a Go package providing an SMTP queue for sending emails and a standalone application that exposes this functionality via an HT

Hectane 221 Jun 18, 2022
Web and API based SMTP testing

MailHog Inspired by MailCatcher, easier to install. Download and run MailHog Configure your outgoing SMTP server View your outgoing email in a web UI

MailHog 10.3k Jun 23, 2022
:incoming_envelope: Simple email interface across multiple service providers (ses, postmark, mandrill, smtp)

go-mail Lightweight email package with multi-provider support (ses, mandrill, postmark) Table of Contents Installation Documentation Examples & Tests

MrZ 39 May 19, 2022
envio de email via SMTP com anexo usando Go

gosendmail - SMTP This repo is a simple net/smtp abstraction for sending emails using SMTP. With it we can send emails With copy, with blind copy and

Jefferson Otoni Lima 8 Dec 16, 2021
Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

Inbucket 1000 Jun 23, 2022
golang honeypot smtp server

honeygogo-smtp standalone honeypot A lightweight SMTP honeypot server written in Go, leveraging go-smtp. A stand alone version of a module from honeyg

jothflee 1 May 4, 2022
Simple SMTP Server for Testing

go-smtptester Simple SMTP Server for Testing. How it works All received mails are saved in a sync.Map with a key: From+Recipient1+Recipient2 Mails to

null 1 Nov 18, 2021
Simple tool to test SMTP mail send with various settings including TLS1.1 downgrade

smtptest Simple tool to test SMTP mail send with various settings including TLS1.1 downgrade All settings are configurable in the config.yaml file ser

Mario 0 Jan 6, 2022
Pretty wrapper for sending email using go net/smtp

Emailer A pretty wrapper around go net/smtp send multiple email using single client func main() { var client *emailer.Client var clientX sync.Mute

Vin. 1 Mar 23, 2022
This small Docker project is the easiest way to send notifications directly via .txt files to services like: Gotify, Telegram, SMTP (Email) or Webhook.

This small Docker project is the easiest way to send notifications directly via .txt files to services like: Gotify, Telegram, SMTP (Email) or Webhook.

echGo 5 Apr 13, 2022
wire protocol for multiplexing connections or streams into a single connection, based on a subset of the SSH Connection Protocol

qmux qmux is a wire protocol for multiplexing connections or streams into a single connection. It is based on the SSH Connection Protocol, which is th

Jeff Lindsay 189 Jun 24, 2022
Eunomia is a distributed application framework that support Gossip protocol, QuorumNWR algorithm, PBFT algorithm, PoW algorithm, and ZAB protocol and so on.

Introduction Eunomia is a distributed application framework that facilitates developers to quickly develop distributed applications and supports distr

Cong 2 Sep 28, 2021
A simple tool to convert socket5 proxy protocol to http proxy protocol

Socket5 to HTTP 这是一个超简单的 Socket5 代理转换成 HTTP 代理的小工具。 如何安装? Golang 用户 # Required Go 1.17+ go install github.com/mritd/[email protected] Docker 用户 docker pull m

mritd 6 Jun 25, 2022
A project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol formatA project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format

Intro This project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format. It integrates nicely with the Telegraf execd inpu

Marc Venturini 1 Apr 15, 2022
Create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compileCreate a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compile

Interview Assignment Overview You assignment is to create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compiler. In this ex

Patrick Valle 0 Nov 19, 2021
A memcached binary protocol toolkit for go.

gomemcached This is a memcached binary protocol toolkit in go. It provides client and server functionality as well as a little sample server showing h

Dustin Sallings 318 Jun 14, 2022
Protocol Buffer compiler written in Go

gotoc This is gotoc, a protocol buffer compiler written in Go. This is only the parser side; you will need a plugin to generate code. Quick Start go g

David Symonds 119 Jan 25, 2022
TiDB is an open source distributed HTAP database compatible with the MySQL protocol

Slack Channel Twitter: @PingCAP Reddit Mailing list: lists.tidb.io For support, please contact PingCAP What is TiDB? TiDB ("Ti" stands for Titanium) i

PingCAP 31.7k Jun 29, 2022
High-performance framework for building redis-protocol compatible TCP servers/services

Redeo The high-performance Swiss Army Knife for building redis-protocol compatible servers/services. Parts This repository is organised into multiple

Black Square Media 414 Jun 22, 2022