GithubHelp home page GithubHelp logo

chococoin / matrix-email-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from t2bot/matrix-email-bot

0.0 2.0 0.0 264 KB

A bot that posts messages to rooms when an email is received.

License: GNU General Public License v3.0

JavaScript 99.57% HTML 0.43%

matrix-email-bot's Introduction

matrix-email-bot

TravisCI badge

A bot that posts messages to rooms when an email is received. Ideal for uses where a short message is desired in a chat room when a newsletter goes out.

Questions? Ask away in #email:t2bot.io

How to use

Note: Currently this is in the early stages of development and is therefore somewhat restricted in what is possible. Future enhancements are planned to make this easier to use and set up.

  1. Invite @email:t2bot.io to your Matrix room.
  2. Get your room's internal ID (for instance, !wpcRmAaQXqgBPdUNWo:t2l.io which is #email:t2bot.io).
  3. Contact @travis:t2l.io (in #email:t2bot.io or a new private chat) to set the appropriate allow_from rule for your room. (This is a temporary step until #1 is implemented)
  4. Send an email to <room id without !>_<domain>@email.t2bot.io (eg: [email protected]).
  5. See the message the bot posts (this may take a while depending on system load).

Subscribing to mailing lists

Please reach out to @travis:t2l.io in #email:t2bot.io (or open a new private chat) to get your room mapped to a mailing list. In the future, this will be better and require less involvement from myself.

Run your own

Note: Some experience with MX records is ideal.

The bot runs best on port 25 to receive all incoming mail to your server. The bot does not (currently) send mail out, but does process all inbound emails to try and get them to the proper room (letting them disappear if no room can be mapped).

  1. Set up an MX record to point to your domain. For example, email.t2bot.io 10 vps3.t2l.io (email.t2bot.io being the domain, 10 the priority, and vps3.t2l.io being the server's hostname)
  2. Optionally install spamassassin and spamc: sudo apt-get install spamassassin spamc - be sure to enable them!
  3. Install nodejs and npm (v6+ preferred).
  4. Clone this repository and run npm install.
  5. Copy config/default.yaml to config/production.yaml and configure accordingly.
  6. Set the environment variable NODE_ENV to production and run node index.js.
  7. Start using your bot!

Running with an existing mail server

TODO: Instructions on how to set up postfix

If mail is currently being managed for your domain, or you'd like to filter the incoming mail in a more intelligent manner before it reaches the bot, set enabled to false under mail in the configuration file. This will disable the default SMTP listener on the bot.

The existing mail server will need to be configured to run an external program so mail can be sent to the bot. Have the mail server run node post_message.js in the bot's directory to post a message from the standard input pipe. If the email is in file form, use the following syntax: node post_message.js path/to/file.eml.

Subscribing to mailing lists

Some mailing lists require you to send an email in order to subscribe. This requires setting up a mailserver (such as postfix) in send-only mode because the bot is handling incoming mail. After setting up your mail server, use it to send an email to the list with the From address being the room you'd like to announce to. For example: echo "Subscribe" | mail -s "Subscribe" [email protected] -aFrom:[email protected]

Security considerations

Currently the bot does some sanitizing on the email received. However, it still ends up going through node-sqlite (or whatever storage backend) which may not completely avoid SQL-injection or similar attacks. Room administrators are expected to set the appropriate restrictions on their rooms to only allow trusted senders and content. The bot also does some sanitizing of the HTML body before storing it to reduce the chance of XSS or similar attacks when sending the email to Matrix or web browser for viewing. Matrix clients (such as Riot) are expected to process that HTML further if desired. For instance, the bot currently allows h1 and h2 tags, Riot does not and therefore Riot is responsible for removing those tags.

matrix-email-bot's People

Contributors

turt2live avatar greenkeeper[bot] avatar dependabot[bot] avatar rubo77 avatar

Watchers

James Cloos avatar  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.