Use respond to an email to trigger specific callbacks.
Project description
README
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for email-keyword-matcher-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1023345eeebb28c0fda1e015cf68e7f7d31324d8503e18fda38dae649c308b06 |
|
MD5 | 8aa229aa35bfb3536a55bf35e3a70299 |
|
BLAKE2b-256 | 38aff4a66d29dd0faf5d22f80e7f6bc0f90bd9adf0c198020c754b7c291eb514 |
Close
Hashes for email_keyword_matcher-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ae5032478decf75a27cbc1428bbc877a402349844b80b06ca18def02794166a |
|
MD5 | b8a9ad09f5313ef68b10bca836322a54 |
|
BLAKE2b-256 | 6b4980a3dc242baed1975660f64901cc1e368d6961956a3cf5cf693a17788615 |