Esempio n. 1
0
def send_verification_email(alert, canary):
    """Send a verification email when someone signs up to watch a 
    canary."""
    if not app.testing:      
        alert = db_session.merge(alert)
        canary = db_session.merge(canary)

    verify_url = config.URL + '/verify/{}?canary={}?email={}'.format(
        alert.hash, canary.id, alert.email)
    canary_url = config.URL + '/canary/{}'.format(canary.sigid_base64)
    msg = format_message('verify_watch_canary', [alert.email],
                         canary_url, verify_url)
    with app.app_context():
        try:
            mail.send(msg)
        except SMTPException as e:
            app.logger.error(e)
Esempio n. 2
0
def notify(canary, user, text):
    """Send an email to notify ``user`` that ``canary`` was published
    with their key and to give them information about republishing
    ``canary``.
    """
    canary = db_session.merge(canary)
    user = db_session.merge(user)

    canary_url = config.URL + '/canary/{}'.format(canary.sigid_base64)
    msg = format_message('new_canary', [user.uid], user.keyid,
                         canary.frequency, canary.freq_type, canary_url,
                         text)

    with app.app_context():
        try:
            mail.send(msg)
        except SMTPException as e:
            app.logger.error(e)
Esempio n. 3
0
def remind(canary, user):
    """Send an email to remind ``user`` to republish ``canary``.
    The email includes a link to a page with a challenge to decrypt.
    """
    if not app.testing:
        canary = db_session.merge(canary)
        user = db_session.merge(user)

    canary_url = config.URL + '/canary/{}'.format(canary.sigid_base64)
    msg = format_message('reminder', [user.uid], canary_url,
                         canary.frequency, canary.freq_type)

    """Set active to False so we don't send another reminder email
    unless the user republishes the canary."""
    canary.active = False
    db_session.commit()
    with app.app_context():
        try:
            mail.send(msg)
        except SMTPException as e:
            app.logger.error(e)