Giter Site home page Giter Site logo

email2slack's Introduction

email2slack

PyPI version Build Status Coverage Status

MIME E-mail forwarding script for Slack(webhook) written in Python.

Demo

Fail2Ban (plain text)

Slack Demo: Plain text Fail2Ban

netdata (HTML)

Slack Demo: HTML netdata

Requirements

  • Python
    • Python 2 >= 2.7
    • Python 3 >= 3.4

Getting Started

Prerequisites

(Optional) Use faster HTML parser than pure Python

Installation of email2slack requires gcc and the development packages of both libxml2 and libxslt. On RedHat based systems you can install these using sudo yum install gcc libxml2-devel libxslt-devel. On Ubuntu systems you can install using sudo apt-get install build-essential libxml2-dev libxslt-dev. If you are using some other system there are probably similar packages available.

(Optional) Use nkf to convert character encoding for non Unicode message

nkf binding module (https://pypi.org/project/nkf/) also requires gcc and Python development headers to build C extension. On RedHat based systems you can install these using sudo yum install gcc python-devel. On Ubuntu systems you can install using sudo apt-get install python python-pip.

Install email2slack

From PyPI

# Install email2slack
pip install -U email2slack  # without any optional modules
pip install -U email2slack[lxml]  # use lxml
pip install -U email2slack[nkf]  # use nkf
pip install -U email2slack[lxml,nkf]  # both

# Fetch configuration file from GitHub
curl https://raw.githubusercontent.com/mikoim/email2slack/master/contrib/email2slack > /usr/local/etc/email2slack

# Before using, You must edit config file
vim /usr/local/etc/email2slack

In this case, setuptools create script to call email2slack and place it in bin directory automatically. So you should use the script in Setup MTA section.

From GitHub repository

git clone https://github.com/mikoim/email2slack.git
cd email2slack

# Install email2slack
pip install -U .  # without any optional modules
pip install -U .[lxml]  # use lxml
pip install -U .[nkf]  # use nkf
pip install -U .[lxml,nkf]  # both
cp contrib/email2slack /usr/local/etc/

# Before using, You must edit config file
vim /usr/local/etc/email2slack

Setup MTA

Postfix

vim /etc/postfix/aliases

...

# notify only, not forward
user: |/usr/local/bin/email2slack

# notify and forward e-mail to another user
user: anotheruser, |/usr/local/bin/email2slack

# notify and leave e-mail on same user
user: \user, |/usr/local/bin/email2slack

# you can override default slack url, team and channel with command line option,
# which replace as default=value in each section.
# -s url / --slack url
# -t team-name / --team team-name
# -c channel-name / --channel channel-name
# -f /path/to/email2slack.conf / --config /path/to/email2slack.conf
user: "|/usr/local/bin/email2slack -c '@user'"
another: "|/usr/local/bin/email2slack -c '#random'"

...

newaliases

Contributors

Thank you for your great work!

  • @komeda-shinji
  • @mmrwoods

email2slack's People

Contributors

mikoim avatar komeda-shinji avatar mmrwoods avatar

Stargazers

 avatar Mohammad Naghavi avatar Dr. Ogg avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

email2slack's Issues

Can this be used without a config file?

Hello,

Nice package and thank you for it. I've used it on a cpanel account (where the server allows python through cloudlinux)

If this can't be used without a config file, it might be nice if it warns you that the config file can't be located. I had some issues because of a typo where I used ~.email2slack rather than ~/.email2slack for the config file.

Hey ho, not really a bug as such, just a suggestion for improvement. I could put together a pull request if you like.

the error I was getting was:-

Traceback (most recent call last):
File "/home/cericoda/virtualenv/email2slack/3.5/bin/email2slack", line 11, in
load_entry_point('email2slack==1.0.0a5', 'console_scripts', 'email2slack')()
File "/home/cericoda/virtualenv/email2slack/3.5/lib/python3.5/site-packages/email2slack/init.py", line 41, in main
Slack(args).notify(mail)
File "/home/cericoda/virtualenv/email2slack/3.5/lib/python3.5/site-packages/email2slack/slack.py", line 160, in notify
self.__post(url[0], self.__payload(
IndexError: list index out of range

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.