Home

Awesome

paws

Build Status

sendmail/maildir interface to Slack. Useful if you use a mail client like Mutt or mu4e and would prefer to communicate with Slack via that client. Supports sending messages via a sendmail-like command, and receiving messages into maildirs, or for further processing by an MDA.

Install

perl Makefile.PL
make
make test
sudo make install

Alternatively, run sudo cpanm . from within the checkout directory. This will fetch and install module dependencies, if required. See https://cpanmin.us.

Basic setup

A user token is needed for each workspace. To generate these tokens:

Occasionally, switching workspaces on the Slack authorisation page will result in an error message: retrying the registration process at that point should make switching unnecessary, and the error can be avoided.

After the tokens have been generated, make a .paws directory in your home directory. Configuration is via a YAML file named config, placed within that directory. A minimal example is like so:

# The addressee for email received from Slack (typically your email
# address).
user_email: "user@example.org"
# Per-workspace configuration.
workspaces:
  # The workspace name.
  myworkspace:
    # The API token for the workspace, generated using `paws-register`.
    token: "xoxp-..."
    # The conversations to fetch from the workspace.  These have
    # the format {type}/{name}, where {type} is one of 'im',
    # 'mpim', 'group', or 'channel'.  Defaults to '*' (i.e. all
    # conversations).
    conversations:
      - "im/slackbot"
      - "channel/general"
# Receiver configuration.
receivers:
    # The type of the receiver.
  - type: "maildir"
    # The workspace for the receiver.
    workspace: "myworkspace"
    # The name of the receiver.  This must be unique for each receiver
    # entry in the configuration file.
    name: "default"
    # Type-specific configuration.  For 'maildir', the only extra
    # configuration is the path to the maildir.
    path: "/home/user/mailbox/slack"
# Sender configuration.
sender:
  # The sendmail command to be used for mail that isn't to be sent
  # to Slack.
  fallback_sendmail: "/usr/sbin/sendmail"
  # The maildir directory to which bounce messages should be
  # written.
  bounce_dir: "/home/user/mailbox/slack-bounce"

If the configuration has been set up correctly, then running paws-receive will fetch all messages from the Slack workspace and write them to the maildir. (If you don't want to fetch all messages, use the --since=YYYY-MM-DD parameter to only fetch messages that were posted on or after the specified date.) Subsequent calls to paws-receive will fetch any new messages that have been posted.

To send messages, configure your mail client to use paws-send as its sendmail command (mail that is not for Slack will be passed off to the fallback_sendmail command). The recipient email addresses for Slack conversations have the form {conversation-name}@{workspace}.slack.alt (e.g. im/slackbot@myworkspace.slack.alt). Email addresses for Slack users have the form {user}@{workspace}.slack.alt (e.g. slackbot@myworkspace.slack.alt). paws-send-queued must also be run periodically, in order to resend messages that have been queued due to temporary problems.

paws-receive takes an optional --persist={n} argument. If provided, then instead of exiting once messages have been received, it will open a persistent connection to Slack and use that to listen for new messages. The argument to --persist is the number of minutes to use as an interval for receiving new messages (messages are not delivered immediately). If the workspace is configured for many channels that are only updated infrequently, using --persist will be much more efficient than simply calling paws-receive periodically. If using --persist in a scheduled job, flock(1) and its --nonblock argument may be useful.

Additional configuration options

Receivers

maildir

Type-specific configuration:

MDA

Type-specific configuration:

Notes

Bugs/problems/suggestions

See the GitHub issue tracker.

Licence

See LICENCE.