Checks IMAP server for new mail and posts it in a Slack channel
- Create a new Incoming Webhook custom integration for your Slack channel (https://slack.com/apps/A0F7XDUAZ-incoming-webhooks)
$ git clone https://github.com/isiah-lloyd/Email2SlackBot.git
$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
- Enter your Webhook URL from Slack into the
settings.example.ini
file along with your email server configuration - Rename
settings.example.ini
tosettings.ini
$ python main.py
- The program is now setup and will check for new mail and post it to slack on subsequent runs
- Run
python main.py
using a cron job
Do not modify last_uid.txt
created by the program but if you are encountering issues it maybe a good idea to regenerate the file by deleting it.
By default, the bot stores the last uid in last_uid.txt
on your local machine. However, by setting storage_location = s3
and setting aws_access_key_id
, aws_secret_access_key
, and aws_s3_bucket_name
in your settings.ini
you can use Amazon S3 for storage.
Ensure your aws_s3_bucket_name
exists on S3.
Deploying to AWS Lambda or other serverless service is an option. Deploying to AWS Lambda is painless with Serverless.
Node.js is required for Serverless deployment. Install Serverless with npm install -g serverless
. Then install the devDependencies with npm install
. Finally, deploy with serverless deploy
.
After deployment, ensure all necessary environment variables are included with your function. You can do this on the AWS console or with the AWS cli.
All serverless configuration is handled in serverless.yml
. By default, serverless.yml
configures the bot to run every 10 minutes.
Quick serverless commands:
- Deploy:
serverless deploy
- Manually invoke a function:
serverless invoke -f run -s [STAGE] -r [REGION] -l
- View the logs for a function:
serverless logs -f run
Note: use --aws-profile [PROFILE]
with these commands if you have more than one set of AWS credentials in your ~/.aws/credentials
file