This file contains hidden or 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 hidden or 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 hidden or 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 = '[email protected]' | |
| recipients = ['[email protected]', '[email protected]', '[email protected]', ] | |
| # create a MIME obj | |
| msg = MIMEMultipart() | 
  
    
      This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 from import Flask, render_template, Response, jsonify, url_for, flash | |
| from flask_sqlalchemy import SQLAlchemy | |
| from flask_httpauth import HTTPBasicAuth | |
| from models import User, Lead, Company | |
| import config | |
| app = Flask(__name__) | |
| db = SQLAlchemy(app) | |
| auth = HTTPBasicAuth() | |
| DEBUG = True | 
  
    
      This file contains hidden or 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
    
  
  
    
  | ############################################################################### | |
| ## Monit control file | |
| ############################################################################### | |
| ## | |
| ## Comments begin with a '#' and extend through the end of the line. Keywords | |
| ## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'. | |
| ## | |
| ## Below you will find examples of some frequently used statements. For | |
| ## information about the control file and a complete list of statements and | |
| ## options, please have a look in the Monit manual. | 
  
    
      This file contains hidden or 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 sys | |
| import os | |
| from click import echo | |
| from flask_mail import Mail | |
| from app import create_app | |
| app = create_app('development') | |
| app.config.update(dict( | |
| MAIL_SERVER='localhost', | |
| MAIL_PORT=1025, |