Example #1
0
def send_password_reset_email(user):
    try:
        recipients = [user.email]
        msg = Message('Password Reset',
                      sender=get_mail_sender(),
                      recipients=recipients)
        msg.html = render_template(
            'auth/reset-password-email.html',
            user=user,
            token=serialize_password_reset_token(user),
        )
        mail.send(msg)
        flash(
            'A password reset email has been sent to {}. This will expire in '
            '10 minutes.'.format(user.email),
            'info',
        )
        return True
    except Exception:
        flash(
            'Could not send a password reset email to {}. Please try again.'.
            format(user.email),
            'danger',
        )
        return False
Example #2
0
def send_verification_email(user, redirect_target=None):
    try:
        recipients = [user.email]
        msg = Message('Verification',
                      sender=get_mail_sender(),
                      recipients=recipients)
        msg.html = render_template(
            'auth/verify-email.html',
            user=user,
            token=serialize_verification_token(user),
            redirect_target=redirect_target,
        )
        mail.send(msg)
        flash(
            'A verification email has been sent to {}. Please verify your '
            'email before logging in to Dawdle.'.format(user.email),
            'info',
        )
        return True
    except Exception:
        flash(
            'Could not send a verification email to {}. Please try again.'.
            format(user.email),
            'danger',
        )
        return False
Example #3
0
def send_delete_account_email(user):
    try:
        recipients = [user.email]
        msg = Message('Dawdle Account Deleted', recipients=recipients)
        msg.html = render_template(
            'user/settings-delete-account-email.html',
            user=user,
        )
        mail.send(msg)
        return True
    except Exception:
        return False
Example #4
0
def send_contact_emails(subject, email, message):
    try:
        recipients = [current_app.config['MAIL_USERNAME']]
        msg = Message('Dawdle: {}'.format(subject), recipients=recipients)
        msg.body = 'From: {}\n\n{}'.format(email, message)
        mail.send(msg)
        recipients = [email]
        msg = Message('Dawdle: {}'.format(subject), recipients=recipients)
        msg.html = render_template('contact/email.html', message=message)
        mail.send(msg)
        flash(
            'We have received your message. '
            'Somebody will get back to you shortly.',
            'success',
        )
        return True
    except Exception:
        flash('Could not send message. Please try again.', 'danger')
        return False
Example #5
0
def send_contact_emails(email, subject, message):
    try:
        # send email to us
        recipients = [current_app.config['CONTACT_EMAIL']]
        msg = Message(subject, sender=get_mail_sender(), recipients=recipients)
        msg.body = 'From: {}\n\n{}'.format(email, message)
        mail.send(msg)

        # send email to user saying we've received their message
        recipients = [email]
        msg = Message(subject, sender=get_mail_sender(), recipients=recipients)
        msg.html = render_template('contact/email.html', message=message)
        mail.send(msg)

        flash(
            'We have received your message. '
            'Somebody will get back to you shortly.',
            'success',
        )

        return True
    except Exception:
        flash('Could not send message. Please try again.', 'danger')
        return False