Skip to content
Utility that logs local sendmail commands to a file instead of using SMTP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This is a small utility that logs outgoing email directly to a file. No SMTP, mail servers, or networking is involved.

Useful when you have a centralized log collector and want to keep records of outbound email in a scalable and searchable fashion.

See for more words about this.

Building and installing

This program only uses the Go standard library and should work with older versions of Go. It has been tested on Go 1.11 and later.

$ go build shim.go
$ sudo -s
# chown root:root shim
# chmod u+s shim
# mv shim /usr/sbin/sendmail

If you want to change the log filename, edit the line in shim.go.


$ /usr/sbin/sendmail
Subject: Test

Hello World
$ tail -1 /var/log/sendmail-shim.log.json
{"time":"2019-07-28T09:25:47Z","uid":"501","username":"hans","arguments":[""],"body":"Subject: Test\n\nHello World\n"}


$ go test
You can’t perform that action at this time.