This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/api/v1/wh/mg/lead/email/delivered', methods=['POST']) | |
def lead_email_delivered(): | |
""" | |
The lead email delivered webhook. | |
:return: json | |
""" | |
if request.method == 'POST': | |
form_data = { | |
"message_id": request.form.get('Message-Id', None), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import hmac | |
def verify(api_key, token, timestamp, signature): | |
hmac_digest = hmac.new(key=mailgun_api_key, | |
msg='{}{}'.format(timestamp, token).encode('utf-8'), | |
digestmod=hashlib.sha256).hexdigest() | |
return hmac.compare_digest(signature, hmac_digest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
lead = db.session.query(Lead).filter( | |
Lead.email_addr == mg_recipient | |
).first() | |
if lead: | |
email = lead.email | |
lead_id = lead.id | |
event = form_data['event'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if request.method == 'POST': | |
form_data = { | |
"message_id": request.form.get('Message-Id', None), | |
"x_mail_gun_sid": request.form.get('X-Mailgun-Sid', None), | |
"domain": request.form.get('domain', 'email.com'), | |
"event": request.form.get('event', 'delivered'), | |
"timestamp": request.form.get('timestamp', None), | |
"recipient": request.form.get('recipient', None), | |
"signature": request.form.get('signature', None), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
# sender details | |
sender = 'alias@domain.org' | |
recipients = ['alias@domain.org', 'email2@domain.com', '3rdrecipients@outloo.com', ] | |
# create a MIME obj | |
msg = MIMEMultipart() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randrange | |
def get_random_ip(): | |
""" | |
Create a random IP address | |
:return: ipv4 address | |
""" | |
return ".".join(str(randrange(1, 255)) for i in range(4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import csv | |
import json | |
from types import * | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import responder | |
import random | |
import logging | |
import uuid | |
from datetime import datetime | |
from marshmallow import Schema, fields | |
api = responder.API( | |
title="ThingsAPI", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!.env/bin/python | |
# -*- coding:utf-8 -*- | |
import config | |
import logging | |
import os | |
import csv | |
import sys | |
import MySQLdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!.env/bin/python | |
# -*- code: utf-8 -*- | |
import sys | |
import csv | |
import config | |
import MySQLdb | |
import logging | |
log_format = '%(asctime)s %(levelname)s:%(message)s' | |
logging.basicConfig( |