All Projects → EFForg → cryptobot-email

EFForg / cryptobot-email

Licence: AGPL-3.0 license
No description, website, or topics provided.

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
CSS
56736 projects
ruby
36898 projects - #4 most used programming language

CryptoBot

CryptoBot Email is an email bot that helps people learn how to use OpenPGP. You send CryptoBot a PGP-encrypted and signed email (probably using GnuPG) and it responds telling you how you do, and offering advice.

Getting Started

Start by copying config_template.py into config.py and editing it.

$ cp config_template.py config.py

Set all of these settings:

  • PGP_NAME: The name part of the user ID for for the bot's OpenPGP keypair
  • PGP_EMAIL: The email part of the user ID for for the bot's OpenPGP keypair. This should be the email address that users are expected to email.
  • GPG_HOMEDIR: The directory in which the bot's keyring will be stored (it will be created by the bot if it does not exist). This should be in a location that is writeable by the bot.
  • USE_MAILDIR: You can either use a Maildir or IMAP; set to False to use IMAP
  • MAILDIR: If you're using a Maildir, this is the path to it
  • IMAP_SERVER: The IMAP server to connect to, e.g. imap.gmail.com
  • IMAP_USERNAME: The IMAP username
  • IMAP_PASSWORD: The IMAP password
  • SMTP_SERVER: The SMTP server to connect to, e.g. smtp.gmail.com
  • SMTP_USERNAME: The SMTP username
  • SMTP_PASSWORD: The SMTP password
  • DATABASE_URL: URL for the unsubscribe database

This is a Python project with some external dependencies. We recommend using virtualenv:

$ virtualenv env
$ . env/bin/activate
(env) $ pip install -r requirements.txt
(env) $ ./bot.py
# when you're done
(env) $ deactivate

Unsubscribes

To avoid exploitation as an automated spam cannon, cryptobot can optionally maintain a database of unsubscribers. It requires one additional setup step. After installing requirements, uncomment the DATABASE_URL in config.py, and run

./unsubscribe.py --setup

This will create the necessary database tables and generate a random salt for hashing email addresses. Once that's done, you can add emails to the database by running

./unsubscribe.py --add [email protected]

Alternatively you can run the included Flask app to serve a simple unsubscribe form for people to unsubscribe themselves.

./app.py    # http://localhost:5000/unsubscribe

For simplicity, you can use an sqlite database, which is created as a normal file in the directory of your choosing, and does not incur any extra dependencies. However, for better concurrency handling, you may want to install and use postgresql, which will require the psycopg2 python module along with some additional system configuration:

sudo apt-get install postgresql
sudo -u postgres createuser -P -s -e cryptobot
createdb cryptobot -O cryptobot
sudo apt-get install postgresql-server-dev-9.1
. env/bin/activate
pip install psycopg
deactivate

Dev Notes

On linux systems: if you get an error while trying to install requirements.txt, like "fatal error: Python.h: No such file or directory" $ sudo apt-get install python-dev

To run the tests:

$ ./test.py

By default, the tests skip key generation, which can be slow and use up entropy. To include these tests, run:

$ ./test.py --slow

Relevant specs:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].