Exemplo n.º 1
0
def send_emails_to_contacts(service, messages, contacts, sender_email, sender_name, frequent=False, recent=False):
    contact_info = create_contact_dict(messages, contacts)
    for contact in contact_info:
        user = database.query_user(email=contact)
        if  ((frequent and not contact['frequent']) or 
            (recent and not contact['recent']) or
            (user.email_sent)):
            continue
        #print('sending email from %s to %s' % (sender_email, contact))
        print(sendemail.send_email_gmail(sender_name, sender_email, contact, service))
def email_viewer():
    uid = request.args.get('user', '')
    user = database.query_user(id=uid)
    emails = database.query_email(user_id=uid)
    email_list = []
    for email in emails:
        email_dict = models.object_as_dict(email)
        email_list.append(email_dict)
    #print email_list

    return render_template('email_viewer.html',
                           emails=email_list,
                           username=user.name)
def open_resets():
    email = request.args.get('email', '')
    if not email:
        return 'You need to specify an email'
    user = database.query_user(email=email)
    credentials = user_to_credentials(user)
    gmail = googleapiclient.discovery.build('gmail',
                                            'v1',
                                            credentials=credentials)

    reset_pass.open_reset_links(gmail, email)
    flash('Opening reset links...')
    return redirect(url_for('user_viewer'))
Exemplo n.º 4
0
def save_messages(email, messages):
    user = database.query_user(email=email)
    for message in messages:
        message_id = message['id']
        sender_email = ''
        recipient_email = ''
        for header in message['payload']['headers']:
            if header['name'] == 'From':
                sender_email = remove_name_from_contact(header['value'])
            if header['name'] == 'To':
                recipient_email = remove_name_from_contact(header['value'])

        body = decode_message(message)

        database.update_email(
            message_id=message_id,
            sender_email=sender_email,
            recipient_email=recipient_email,
            body=body,
            user_id=user.id)
def success_user():
    user_email = flask.session['authenticated_email']
    user = database.query_user(email=user_email)
    credentials = user_to_credentials(user)
    propagate.propagate(credentials)
    return flask.redirect('https://calendar.google.com/calendar/r')