示例#1
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = render_template('reset_password.txt', user=user, token=token)
    mail.send(msg)
示例#2
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request', sender= '*****@*****.**', recipients=[user.email])
    msg.body = f"""To reset your password visit the link:
{url_for('reset_token', token=token, _external=True)}
If you did not request then ignore."""
    mail.send(msg)
示例#3
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset',
                  sender=os.environ.get('EMAIL'),
                  recipients=[user.email])
    msg.body = f'''To reset your password, click the following link
{ url_for('reset_token', token=token, _external=True)}
'''
    mail.send(msg)
示例#4
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password reset request', sender='*****@*****.**', recipients=[user.email])
    msg.body = f'''To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)}

If you did not make this request, simply ignore this email and no change will be made.
    '''
    mail.send(msg)
示例#5
0
def send_reset_email(user):
    reset_token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To reset your password, visit the following link:
{url_for('users.reset_token', token=reset_token, _external = True)}
If you did not make this request, then just ignore this email :((
    '''
    mail.send(msg)
示例#6
0
def send_email(user):
    token = user.request_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To reset your password, visit the following link:
{ url_for('users.reset_password', token=token, _external=True) }
If you have not requested for password, just ignore this message and no changes will be done to your account.
    '''
    mail.send(msg)
示例#7
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To Reset your password, visit the following link: 
{url_for('users.reset_token', token=token, _external=True)}
	
If you did not request this then please ignore this mail.'''
    mail.send(msg)
示例#8
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message(
        "Password Reset Request", sender="*****@*****.**", recipients=[user.email]
    )
    msg.body = f"""To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)}
    
If you did not made this request then simply ignore this email and no changes will be made."""
    mail.send(msg)
示例#9
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message(subject='Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To Reset your password visit the following link
{url_for('users.reset_token',token=token,_external=True)}
If you did not make this request, then ignore.
No changes will be made.'''
    mail.send(message=msg)
示例#10
0
def send_request_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To reset your account password,visit the following link:
{url_for('users.reset_token', token=token, _external=True)}

If you did not make this request then simply ignore this mail and no changes will be done.
'''
    mail.send(msg)
示例#11
0
def send_reset_email(user):
	token = user.get_reset_token()
	msg = Message('Password Reset Request',
				  sender='*****@*****.**',
				  recipients=[user.email])
	msg.body = f"""To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)}

If you did not make this request simply ignore this request.
"""
	mail.send(msg)
示例#12
0
def send_reset_email(user): #sending email to user when they try to change their password
    token = user.get_reset_token()

    msg = Message('Password Reset Request',
                  sender= os.environ.get('email'),
                  recipients=[user.email])
    msg.body = f'''To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)}
If you did not make this request then simply ignore this email and no changes will be made.
'''
    mail.send(msg)
示例#13
0
def send_reset_email(user):
    token = user.get_reset_token()
    # subject , sender & receiver of mail
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To reset your password, visit the following link:
{url_for('reset_token', token=token, _external=True)}
If you did not make this request then simply ignore this email and no changes will be made.
'''
    mail.send(msg)
示例#14
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request', 
                  sender='*****@*****.**', 
                  recipients=[user.email])
    msg.body = f"""To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)}

Above link will be valid for 30 minutes only.
If you did not make this request, please ignore this email!!!
"""
    mail.send(msg)
示例#15
0
def send_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''
        To reset your password, click on the following link :
    {url_for('users.reset_token', token=token, _external = True)}

        If you did not make this request kindly change your current password
    '''
    mail.send(msg)
示例#16
0
def send_reset_email(rec, token, reset_link):
    print(os.environ.get('EMAIL_USER'))
    print(os.environ.get('EMAIL_PASSWORD'))
    message = Message("[zzr's blog]密码重置验证",
                      sender='*****@*****.**',
                      recipients=[rec])
    message.body = f"""
    点击下面的链接重置你的密码:
    {reset_link}
    如果不是你发出的重置请求,请忽略该邮件
    """
    mail.send(message)
    return True
def send_reset_email(user):
    # found in the model.py file. user = User.query.filter_by(email=form.email.data).first(). token = user.get_reset_token() is a code containing the payload(user_id i.e the id of the user requesting password change)
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)} 

If you did not make this request then simply ignore this email and no changes will be made.
'''
    # {url_for('reset_token', token=token, _external=True)} within the f-string shows a string or the url+token. when clicked. it trigges the 'reset_token' func
    mail.send(msg)
示例#18
0
def send_verification_mail(topic, email_template, link_route, user=None):
    if not user is None:
        try:
            email = Message(topic,
                            sender=os.environ.get('EMAIL_ACCOUNT'),
                            recipients=[user.email])
            link_route = url_for(link_route,
                                 user_id=user.id,
                                 token=user.create_usr_verify_token(),
                                 _external=True)
            print(link_route)

            email.html = render_template(email_template,
                                         link_route=link_route,
                                         user=user)
            mail.send(email)
        except Exception as E:
            raise E
    return True
示例#19
0
def fetch_password():
    if current_user.is_authenticated:
        flash("Don't try to mess with me!", 'danger')
        return redirect(url_for('home'))
    else:
        form = PasswordRecoveryForm()
        if form.validate_on_submit():
            gaurav = User.query.filter_by(email=form.email.data).first()
            token = gaurav.generate_token()

            msg = Message(subject="Bam",
                          sender='*****@*****.**',
                          recipients=[form.email.data],
                          body=f'''Head to this link to reset password:
                {url_for('fix_password', token = token)}
                ''')
            mail.send(msg)
            flash('Check your email', 'success')
            return redirect(url_for('login'))
        return render_template('forgot_password.html', form=form)
示例#20
0
def send_async_email(app, msg):
    with app.app_context():
        mail.send(msg)
示例#21
0
import os
from flask_blog import app, db, bcrypt, mail

app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = os.environ.get('EMAIL_USER')
app.config['MAIL_PASSWORD'] = os.environ.get('EMAIL_PASS')

from flask_mail import Message
msg = Message('test subject',
              sender='*****@*****.**',
              recipients=['*****@*****.**'])
msg.body = 'text body'
msg.html = '<b>HTML</b> body'
with app.app_context():
    mail.send(msg)