示例#1
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message("Password Reset Request", sender="*****@*****.**", recipients = [user.email])
    msg.body = f'''Per resettare la password, segui questo link: {url_for('users.reset_token', token=token, _external=True)}

    Se non hai fatto questa richiesta, ignorala.'''
    mail.send(msg)
示例#2
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        unique_check = User.query.filter_by(email=form.email.data).first()
        if not unique_check:
            unique_check = User.query.filter_by(
                username=form.username.data).first()
            if unique_check:
                return redirect(url_for('users.register'))
        else:
            return redirect(url_for('users.register'))
        token = confirm.dumps(form.email.data, salt='salt.email.confirm')
        db.session.add(user)
        db.session.commit()
        flash('Thanks for registration!')
        msg = Message('Please confirm your email!',
                      sender='*****@*****.**',
                      recipients=[form.email.data])
        link = url_for('users.confirmation', token=token, _external=True)
        msg.body = 'Congrats! You have been registered. Email confirmation link: {}'.format(
            link)
        mail.send(msg)
        return redirect(url_for('users.login'))
    return render_template('register.html', form=form)
示例#3
0
def send_reply_email(id, new_reply):
    comment = Comment.query.get(id)
    replies = Reply.query.filter_by(replied=comment).all()
    email_commenter = [comment.email]
    email_of_previously_replied = []
    if replies:
        for reply in replies:
            if reply.email != "AnonymousUser":
                email_of_previously_replied.append(reply.email)
        msg_repliers = Message("Notification From Blog It",
                               sender="*****@*****.**",
                               recipients=email_of_previously_replied)
        msg_repliers.body = f'''Someone also replied to a post you replied to. 
		{url_for("posts.comment_replies",id=id,_external=True)}

{new_reply.comment[0:int(len(new_reply.comment)/3)]}
			
		
		
		
		
		'''

    msg_commenter = Message("Notification From Blog It",
                            sender="*****@*****.**",
                            recipients=email_commenter)
    msg_commenter.body = f'''
Someone replied to a comment you made on blogit
'{url_for("posts.comment_replies",id=id,_external=True)}'

{new_reply.comment[0:int(len(new_reply.comment)/3)]}
	
	'''
    mail.send(msg_commenter)
示例#4
0
文件: email.py 项目: CoCongV/Blog
def send_email(to, subject, template, **kwargs):
    app = current_app._get_current_object()
    msg = Message(app.config['FLASK_MAIL_SUBJECT_PREFIX'] + ' ' + subject,
                  sender=app.config['FLASK_MAIL_SENDER'],
                  recipients=[to])
    msg.html = render_template(template + '.html', **kwargs)
    mail.send(msg)
示例#5
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 then simply ignore this email and no changes will be made.
'''
    mail.send(msg)
示例#6
0
def send_reset_email(user):
    token = user.get_reset_token()  # 获取 token 默认有效期 1800s
    msg = Message("重置密码", recipients=[user.email])
    msg.body = f"""重置密码,请访问链接:
    {url_for('reset_token', token=token, _external=True)}
    如果您没有提出此请求,只需要忽略此电子邮件,不做任何更改请求。"""  # 为 True 是为了获得绝对 URL
    mail.send(msg)
示例#7
0
def resent_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('reset_token', token=token, _external=True)}
"""
    mail.send(msg)
示例#8
0
def forgot_password():
    form = ForgotPasswordForm()

    if (form.validate_on_submit() or request.method == "POST"):
        email = form.email.data
        user = User.query.filter_by(email=email).first()

        if (not user):
            flash("There is no account registered using this email id")
            return redirect(url_for('user.register'))
        else:
            if (not user.confirmed):
                db.session.delete(user)
                db.session.commit()

                flash(
                    "You had not confirmed your email. Your account has been deleted. Please re-open a new account."
                )
                return redirect(url_for('user.register'))
            else:
                try:
                    token = serializer.dumps(email, salt='forgot-confirm')
                    link = url_for('user.change_password',
                                   token=token,
                                   _external=True)

                    msg = Message('Blog Tap Password Reset',
                                  sender='*****@*****.**',
                                  recipients=[email])

                    msg.body = f'''
\tWelcome Blogger!

Hello {user.username}.
Please click on the link below to reset your password at Blog Tap.
Your reset link is: {link}
If you didn't request password reset, please ignore this mail.
Hope you have an awesome time.
        
\tYour Sincerely
\tTapajyoti Bose
\tCreator
\tBlog Tap
'''

                    mail.send(msg)

                    flash(
                        f'Password reset mail has been sent. Please reset your password within 48 hours.'
                    )
                    return redirect(url_for('user.login'))

                except:
                    flash('We were unable to send the password reset mail.')
                    return redirect(url_for('core.index'))

    return render_template('forgot-pass.html', form=form)
def send_verification_email(user):
    msg = Message(subject='Email Verification',
                  sender='*****@*****.**', recipients=[user.email])
    otp = randint(100000, 999999)
    msg.body = f"""Please register with the following otp :-
{otp}
    """
    mail.send(msg)
    return otp
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message(subject='Password Reset Link',
                  sender='*****@*****.**', recipients=[user.email])
    msg.body = f"""To reset password click the following link:-
{url_for('user_accounts.reset_password',token=token, _external=True)}
If you didn't made this request just ignore this email.
The link is only valid for 30 minutes.
    """
    mail.send(msg)
示例#11
0
def send_reset_password_email(user):
    token = user.generate_reset_token()
    message = Message('Reset Password Request',
                      sender='*****@*****.**',
                      recipients=[user.email])
    message.body = f'''Visit bellow link to reset your password:
{url_for('user.reset_token', token=token, _external=True)}.
If you did not request for a password reset leave it as it is, nothing will change. 
    '''
    mail.send(message)
示例#12
0
def send_reset_email(user):
    token = user.get_reset_token()
    print(token)
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''To Rest your password visit following link 
{url_for('users.reset_token', token=token, _external=True)}
If you did not make this request simply ignore this.'''
    mail.send(msg)
示例#13
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 following link:
{url_for('users.reset_token', token=token, _external=True)} 

If you did not make this request then simply ignore this email.'''
    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 password, visit the following link:
    {url_for('users.reset_token', token=token, _external=True)}

    If you didn't make this request, freak out
    '''
    mail.send(msg)
示例#15
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 then just ignore this message and no changes will be made.
'''
    mail.send(msg)
示例#16
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request - BlogPost',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f''' To reset your password, visit the following link: 
{ url_for('reset_password', token = token, _external = True)}

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

if you did not make this request the ignore this email
'''
    mail.send(msg)
示例#18
0
def send_async_email(app, msg: Message):
    """
    Send in thread helper
    :param app: Current application instance
    :type app: LocalProxy
    :param msg: Generated email message
    :type msg: Message
    """

    with app.app_context():
        mail.send(msg)
示例#19
0
def sendResetEmail(user):
    token = user.get_reset_token()
    message = Message("Password Reset Request", 
                    sender = "*****@*****.**", 
                    recipients=[user.email])
    message.body = f'''To reset your password, please visit the following link:
{url_for("users.resetToken", token=token, _external=True)}

If you did not make this request, please ignore this email.
'''
    mail.send(message)
示例#20
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message("Password Reset Request",
                  sender="*****@*****.**",
                  recipients=[user.email])
    msg.body = f''' If you want to reset your password click this link:
{url_for("reset_token",token = token, _external = True)}

If this mail is not in your information please just ignore.    
'''
    mail.send(msg)
示例#21
0
def send_confirmation_email(email, token):

    msg = Message('Please, confirm your FlaskBlog account',
                  sender='*****@*****.**',
                  recipients=[email])
    link = url_for('confirm_email', token=token, _external=True)
    msg.body = "This is FlaskBlog. Please, confirm your e-mail.\n\
    Don\'t reply on this message. \nYour confirmation link: {}".format(link)
    mail.send(msg)
    return '<h3>The mail you entered is {}. The token is {}</h3>'.format(
        email, token)
示例#22
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 click on the given link :
    {url_for('users.reset_token', token=token, _external=True)}

    If do not want to reset the password ignore this mail.
    '''
    mail.send(msg)
示例#23
0
def send_email(user):
	token = user.get_reset_token() # get token of current user
	msg = Message('Password reser request', sender='*****@*****.**',
				   recipients=[user.email])
	msg.body = f'''To reset your password follow the provided link:
{url_for('users.reset_token', user=user, token=token, _external=True)}

If you didn't request this email then ignore it.
ありがとうございます
'''
	mail.send(msg)
示例#24
0
def send_reset_email(user):
    token = user.get_reset_token(expires_sec=1800)
    msg = Message("Password Reset Request",
                  sender="*****@*****.**",
                  recipients=[user.email])
    msg.body = f''' To reset password visit:
{url_for('reset_token', token=token, _external=True)}

If you didn't request, don't change anything!
    '''
    mail.send(msg)
示例#25
0
def send_comment_email(id, new_comment):
    post = Post.query.get(id)
    author_email = post.author.email
    msg = Message("Comment Notification from blogIt",
                  sender="*****@*****.**",
                  recipients=[author_email])
    msg.body = f"""
Someone Commented on your post on Blogit.
{url_for("posts.post",id=post.id,_external=True)}.
{new_comment.comment[0:int(len(new_comment.comment)/3)]}
	"""
    mail.send(msg)
示例#26
0
def send_reset_email(user):
    token = user.get_reset_token()
    print(f"token is {token}")
    msg = Message('Password Rest Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = '''To Reset your password, visit the following link:
<resetlink>

If you did not make this request then simply ignore this email and no changes will be made
'''
    mail.send(msg)
示例#27
0
def send_reset_email(user):
    token = user.get_reset_token()
    message = Message('Password Reset Request',
                      sender='*****@*****.**',
                      recipients=[user.email])
    # external=True to get absolute url
    message.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 this email. No changes will be made
'''
    # send the message
    mail.send(message)
示例#28
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('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)
示例#29
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    # the "_external=True" shows the ABSOULTE path, not relative path
    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, please ignore this email.
'''
    mail.send(msg)
示例#30
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password reset request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    # user _external to get an absolute URL rather than relative URL
    msg.body = f'''To reset your password, vist the following link:
    {url_for('users.reset_token', token=token, _external=True)}
    If you did not make this request, please ignore this email changes be made
    '''
    # send the mail to user's mail
    mail.send(msg)