Skip to main content

Use respond to an email to trigger specific callbacks.

Project description

README

Continuous Integration codecov

Send an email and perform an action when a user responds with one of a set of keywords.

This currently has been tested using Gmail as a less secure app.

Features

  • Runs a callback function if the email reply is a keyword
  • Email the replier saying no keyword was found if the reply email doesn't contain a keyword
  • Check if an email has been replied to

Usage

pip install email-keyword-matcher
from email_keyword_matcher import EmailKeywordMatcher
import time

host = 'smtp.gmail.com'
port = 567
sender_email = 'foo@bar.com'
receiver_email = 'bar@baz.com'
password = 'super-secret-password'

# Create an `EmailKeywordMatcher` object
#
# Note if you don't pass in credentials, you will be prompted
# for them
ekm = EmailKeywordMatcher(sender_email, password, host, port)

# Create keywords that will be looked for in the reply
# and associate a callback with them
ekm.add_keyword('done', lambda: print("'done' called"))
ekm.add_keyword('snooze', lambda: print("'snooze' called"))
ekm.add_keyword('cancel', lambda: print("'cancel' called"))

# Send and email
email_subject = "Checkin"
email_content = "Make sure to checkin"
ekm.send(receiver_email, email_subject, email_content)

# Check if that email has been replied to
while not ekm.is_response(receiver_email, email_subject):
    print("No email back yet")
    time.sleep(5)

# Perform the callback for the found keyword, or
# send another email to `receiver_email` saying that
# a valid keyword was not found.
ekm.process_received(receiver_email, email_subject)

Meta

Audrow Nash - @audrow - audrow@hey.com

Distributed under the MIT license. See LICENSE.txt for more information.

https://github.com/audrow/email-keyword-matcher

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

email-keyword-matcher-1.0.0.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

email_keyword_matcher-1.0.0-py2.py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 2 Python 3

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