Skip to main content

MIME E-mail forwarding script for Slack written in Python

Project description

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

Slack Demo: Plain text Fail2Ban

netdata (HTML)

Slack Demo: HTML netdata

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

email2slack-1.0.0a6.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

email2slack-1.0.0a6-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file email2slack-1.0.0a6.tar.gz.

File metadata

  • Download URL: email2slack-1.0.0a6.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for email2slack-1.0.0a6.tar.gz
Algorithm Hash digest
SHA256 4b993d00eccf0eca5605b01cac7e937c2b792d7e35262240bc8a91f007e88bb1
MD5 923c370e9aa0e6b111f0e0cb79ed3ad0
BLAKE2b-256 ab13d71b98237828394944fa92c40ed4ad7a78e94c43d333833752f2ec816fe0

See more details on using hashes here.

File details

Details for the file email2slack-1.0.0a6-py3-none-any.whl.

File metadata

  • Download URL: email2slack-1.0.0a6-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for email2slack-1.0.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 c3bb24bd52eb0ff01303d03687eb559208283b49fdb97caa8f75e7b264008804
MD5 2d742b986c28a07b0ef88fa8559430aa
BLAKE2b-256 88dc5020e59a58dfce56103aa3c25ea3017f98f9da1b7a01476c210ee4b8bae4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page