Пример #1
0
def send_register_email(user):
    ''' User register. Send him an email to verify email address before creating account. '''
    expires_sec = 3600 * 24 * 7
    s = Serializer(app.config['SECRET_KEY'], expires_sec)
    token = s.dumps({'user_id': user.id}).decode('utf-8')
    msg = Message('Katagui Email Verification',
                  sender='*****@*****.**',
                  recipients=[user.data['email']])
    msg.body = f'''
{tr( 'visit_link_activate')}

{url_for('verify_email', token=token, _external=True)}

{tr( 'register_ignore')}
    '''
    mail.send(msg)
Пример #2
0
def ttest():
    msg = Message('Python test',
                  sender='*****@*****.**',
                  recipients=['*****@*****.**'])
    msg.body = 'hi there from python'
    ret = mail.send(msg)
    return render_template('ttest.tmpl', msg='ttest')
Пример #3
0
def send_reset_email(user):
    ''' User requested a password reset. Send him an email with a reset link. '''
    expires_sec = 3600 * 24 * 7
    s = Serializer(app.config['SECRET_KEY'], expires_sec)
    token = s.dumps({
        'user_id': user.id,
        'lang': user.data.get('lang', 'eng')
    }).decode('utf-8')
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.data['email']])
    #msg.body = 'hi there testing a reset'
    tstr = f'''
{tr( 'visit_link_password')}

{url_for('reset_token', token=token, _external=True)}

{tr( 'password_ignore')}
    '''
    msg.body = tstr
    mail.send(msg)