Giter VIP home page Giter VIP logo

sendmail-to-matrix's Introduction

sendmail-to-matrix

Forward locally received emails (admin notifications, etc) to a Matrix room.

THIS PROJECT IS IN ALPHA, BUT IT WORKS AND I USE IT :)

Background

Proxmox can only send email notifications. Since they didn't work with the email service I wanted to use, I decided to use Matrix (which I use elsewhere anyway).

I wanted a minimal one-way bridge, wherein I could configure Proxmox to send email notifications to a local email address (matrix@localhost in my case) and the body of each email would be forwarded to my Matrix room.

Installation

This project is written in go and is released as a statically-linked binary meaning it has no dependencies.

The recommended installation method is to download the binary from the releases page.

Alternatively, build it yourself:

git clone https://github.com/tnyeanderson/sendmail-to-matrix.git
cd sendmail-to-matrix
CGO_ENABLED=0 go build .

Configuration

You must add a config file that will be used by the script, or supply a server, token, and room with command-line parameters.

Values from a config file are overwritten by command-line parameters. See sendmail-to-matrix --help for help.

NOTE: CLI options can have a few different formats, but it is recommended to use the double-hyphen syntax (--config-file instead of -config-file) for consistency with other standard applications.

Ensure that sendmail-to-matrix is executable:

chmod +x /path/to/sendmail-to-matrix

Generate a config file by following the prompts:

/path/to/sendmail-to-matrix generate-config

Note: You can place the configuration file anywhere the script can read from as long as you specify it using --config-file /path/to/config.json

Add the following line to /etc/aliases to pipe emails sent to myuser@localhost to the script:

myuser: "|/path/to/sendmail-to-matrix --config-file /path/to/config.json"

Note: The alias can also be added to the user's ~/.forward file.

Reload your aliases:

newaliases

Testing

To test that emails get forwarded properly, use sendmail (press CTRL+D after you have finished typing your message):

$ sendmail myuser@localhost
> Subject: THIS IS NOT A TEST
>
> A song by Bikini Kill

You should receive the following message in your Matrix room (based on the example configuration above):

Sent from my homelab
Subject: THIS IS NOT A TEST
A song by Bikini Kill

Alternatively, you can test with a file that contains an email in standard Linux mailbox form.

cat email.txt | /path/to/sendmail-to-matrix

You're done! Direct any administration-related emails (Proxmox notifications, sysadmin stuff, monitoring, the works) to myuser@localhost (or whatever you created as your alias) and enjoy getting notifications in a modern way.

Caveats

  • HTML tags are removed from the parts of type text/html
  • Messages with type multipart/alternative will prefer text/plain.

sendmail-to-matrix's People

Contributors

tnyeanderson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.