예제 #1
0
def generate_invite(sender_name, sender_email, recipient, service_name,
                    invite_token):
    assert sender_email != recipient

    subject = '%s has given you access to %s' % (sender_name, service_name)

    login_url = 'https://www.mitro.co/login/google'
    if invite_token is not None:
        login_url += '/' + invite_token

    variables = {
        'sender_name': sender_name,
        'sender_email': sender_email,
        'service_name': service_name,
        'login_url': login_url,
    }

    html = _generate_template('email_invite.html', variables, html_escape=True)
    text = _generate_template('email_invite.txt', variables, html_escape=False)

    message = sendmail.make_email_message(html, subject, recipient, _FROM_ADDR,
                                          text)
    # Dropbox sets reply-to to the "sharerer"
    message['Reply-To'] = sender_email.encode('us-ascii')
    return message
예제 #2
0
def generate_share_notification(sender_name, sender_email, recipient_name, recipient_email, secret_title, secret_url):
    '''Generate an email when a new service is shared with a user.'''
    if not sender_name:
        sender_name = sender_email
    if not recipient_name:
        recipient_name = recipient_email
    if not secret_title:
        secret_title = secret_url

    params = {
        'sender_name': sender_name,
        'sender_email': sender_email,
        'recipient_name': recipient_name,
        'recipient_email': recipient_email,
        'secret_title': secret_title,
        'secret_url': secret_url
    }

    subject = '%s has shared a secret with you' % sender_name

    html = _generate_template('share_notification.html', params, html_escape=True)
    text = _generate_template('share_notification.txt', params, html_escape=False)
    text = ''

    message = sendmail.make_email_message(html, subject, recipient_email, _FROM_ADDR, text)

    return message
예제 #3
0
def generate_share_notification(sender_name, sender_email, recipient_name,
                                recipient_email, secret_title, secret_url):
    '''Generate an email when a new service is shared with a user.'''
    if not sender_name:
        sender_name = sender_email
    if not recipient_name:
        recipient_name = recipient_email
    if not secret_title:
        secret_title = secret_url

    params = {
        'sender_name': sender_name,
        'sender_email': sender_email,
        'recipient_name': recipient_name,
        'recipient_email': recipient_email,
        'secret_title': secret_title,
        'secret_url': secret_url
    }

    subject = '%s has shared a secret with you' % sender_name

    html = _generate_template('share_notification.html',
                              params,
                              html_escape=True)
    text = _generate_template('share_notification.txt',
                              params,
                              html_escape=False)
    text = ''

    message = sendmail.make_email_message(html, subject, recipient_email,
                                          _FROM_ADDR, text)

    return message
예제 #4
0
def generate_new_user_invite(sender_email, recipient_email, temp_password):
    assert sender_email != recipient_email

    subject = '%s has shared an account with you' % (sender_email)

    args = {
        'u': recipient_email,
        'p': temp_password,
    }
    login_url = 'https://www.mitro.co/install.html' + '#' + \
        urllib.urlencode(args)

    variables = {
        'sender_email': sender_email,
        'recipient_email': recipient_email,
        'temp_password': temp_password,
        'login_url': login_url,
    }

    html = _generate_template('new_user_invite.html',
                              variables,
                              html_escape=True)
    text = _generate_template('new_user_invite.txt',
                              variables,
                              html_escape=False)

    return sendmail.make_email_message(html, subject, recipient_email,
                                       _FROM_ADDR, text)
예제 #5
0
def send_address_verification(recipient_email, verification_code):
    subject = 'Verify your Mitro account'

    args = {
        'user': recipient_email,
        'code': verification_code,
    }
    verification_link = 'https://www.mitro.co/mitro-core/user/VerifyAccount?' + \
        urllib.urlencode(args)

    variables = {
        'verification_link': verification_link
    }
    html = _generate_template('address_verification.html', variables, html_escape=True)
    text = _generate_template('address_verification.txt', variables, html_escape=False)
    message = sendmail.make_email_message(html, subject, recipient_email, _FROM_ADDR, text)
    if ok_to_send_email(recipient_email):
        _send(message)
예제 #6
0
def send_device_verification(recipient_email, token, token_signature):
    subject = 'Mitro: Verify your account for a new device'

    args = {
        'user': recipient_email,
        'token': token,
        'token_signature': token_signature
    }
    verification_link = 'https://www.mitro.co/mitro-core/user/VerifyDevice?' + \
        urllib.urlencode(args)

    variables = {
        'verification_link': verification_link
    }
    html = _generate_template('device_verification.html', variables, html_escape=True)
    text = _generate_template('device_verification.txt', variables, html_escape=False)
    message = sendmail.make_email_message(html, subject, recipient_email, _FROM_ADDR, text)

    if ok_to_send_email(recipient_email):
        _send(message)
예제 #7
0
def send_issue_reported(user_email_address, url, issue_type, description, issue_id):
    subject = 'Mitro issue report (id: %s url: %s)' % (issue_id, url)
    recipient_email = _EMAILS_TO_SEND_ISSUES_TO
    user_email_address = user_email_address.strip()
    variables = {
        'issue_id': issue_id,
        'user_email': user_email_address,
        'url' : url,
        'issue_type' : issue_type,
        'description' : description
    }

    text = _generate_template('new_issue.txt', variables, html_escape=False)
    message = sendmail.make_email_message('', subject, recipient_email, _FROM_ADDR, text)
    # The user supplied a "valid" email address: set the reply-to header
    # If we set it for invalid strings, the server rejects the message
    if _is_valid_email(user_email_address) > 0:
        message['Reply-To'] = user_email_address

    _send(message)
예제 #8
0
def send_address_verification(recipient_email, verification_code):
    subject = 'Verify your Mitro account'

    args = {
        'user': recipient_email,
        'code': verification_code,
    }
    verification_link = 'https://www.mitro.co/mitro-core/user/VerifyAccount?' + \
        urllib.urlencode(args)

    variables = {'verification_link': verification_link}
    html = _generate_template('address_verification.html',
                              variables,
                              html_escape=True)
    text = _generate_template('address_verification.txt',
                              variables,
                              html_escape=False)
    message = sendmail.make_email_message(html, subject, recipient_email,
                                          _FROM_ADDR, text)
    if ok_to_send_email(recipient_email):
        _send(message)
예제 #9
0
def send_issue_reported(user_email_address, url, issue_type, description,
                        issue_id):
    subject = 'Mitro issue report (id: %s url: %s)' % (issue_id, url)
    recipient_email = _EMAILS_TO_SEND_ISSUES_TO
    user_email_address = user_email_address.strip()
    variables = {
        'issue_id': issue_id,
        'user_email': user_email_address,
        'url': url,
        'issue_type': issue_type,
        'description': description
    }

    text = _generate_template('new_issue.txt', variables, html_escape=False)
    message = sendmail.make_email_message('', subject, recipient_email,
                                          _FROM_ADDR, text)
    # The user supplied a "valid" email address: set the reply-to header
    # If we set it for invalid strings, the server rejects the message
    if _is_valid_email(user_email_address) > 0:
        message['Reply-To'] = user_email_address

    _send(message)
예제 #10
0
def send_device_verification(recipient_email, token, token_signature):
    subject = 'Mitro: Verify your account for a new device'

    args = {
        'user': recipient_email,
        'token': token,
        'token_signature': token_signature
    }
    verification_link = 'https://www.mitro.co/mitro-core/user/VerifyDevice?' + \
        urllib.urlencode(args)

    variables = {'verification_link': verification_link}
    html = _generate_template('device_verification.html',
                              variables,
                              html_escape=True)
    text = _generate_template('device_verification.txt',
                              variables,
                              html_escape=False)
    message = sendmail.make_email_message(html, subject, recipient_email,
                                          _FROM_ADDR, text)

    if ok_to_send_email(recipient_email):
        _send(message)
예제 #11
0
def generate_invite(sender_name, sender_email, recipient, service_name, invite_token):
    assert sender_email != recipient

    subject = '%s has given you access to %s' % (sender_name, service_name)

    login_url = 'https://www.mitro.co/login/google'
    if invite_token is not None:
        login_url += '/' + invite_token

    variables = {
        'sender_name': sender_name,
        'sender_email': sender_email,
        'service_name': service_name,
        'login_url': login_url,
    }

    html = _generate_template('email_invite.html', variables, html_escape=True)
    text = _generate_template('email_invite.txt', variables, html_escape=False)

    message = sendmail.make_email_message(html, subject, recipient, _FROM_ADDR, text)
    # Dropbox sets reply-to to the "sharerer"
    message['Reply-To'] = sender_email.encode('us-ascii')
    return message
예제 #12
0
def generate_new_user_invite(sender_email, recipient_email, temp_password):
    assert sender_email != recipient_email

    subject = '%s has shared an account with you' % (sender_email)

    args = {
        'u': recipient_email,
        'p': temp_password,
    }
    login_url = 'https://www.mitro.co/install.html' + '#' + \
        urllib.urlencode(args)

    variables = {
        'sender_email': sender_email,
        'recipient_email': recipient_email,
        'temp_password': temp_password,
        'login_url': login_url,
    }

    html = _generate_template('new_user_invite.html', variables, html_escape=True)
    text = _generate_template('new_user_invite.txt', variables, html_escape=False)

    return sendmail.make_email_message(html, subject, recipient_email, _FROM_ADDR, text)