Skip to content

📨 Send emails right from your terminal.

License

Notifications You must be signed in to change notification settings

actcoding/smtp-cli

Repository files navigation

smtp-cli

📨 Send emails right from your terminal.

We use this tool to send an informational email whenever someone logs in to one of our servers. Intended usage is via pam_exec(8).

Emails are sent directly via SMTP. The config is read from a json file, see Config.

The message body is produced via go templates, see Templates.

Installation

Download an archive (.tar.gz) from the latest release and run the install.sh script.

Usage

Add the following snippet to /etc/pam.d/sshd:

session required pam_exec.so /usr/local/bin/smtp-cli -config /usr/local/etc/smtp-cli/config.json -template /usr/local/etc/smtp-cli/template.gotmpl 

Config

{"host": "mail.example.org", "port": 465, "username": "[email protected]", "password": "", "from": "monitor <[email protected]>", "to": [ "info <[email protected]>" ], "subject": "New login to the server" }

Templates

The following variables are made available to the go template:

VariableType
Hoststring
Userstring
RemoteUserstring
RemoteHoststring
Ttystring
Timestamptime.Time

License

MIT

About

📨 Send emails right from your terminal.

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •