Exemplo n.º 1
0
def send_reset_email(user):
    """For reset password make an email for existed user

    Arguments:
        user {object} -- To reset password. when user want to reset password this function
        will send mail of reset password to user's submitted/registered mail for verification.
    """
    token = user.get_reset_token()
    mail_file = os.path.join(APP_PATH, "templates", "users", "password-reset",
                             "content.txt")
    with open(mail_file, "r") as f:
        msg_text = f.read()
    msg_text = msg_text.format(
        name=user.username,
        action_url=url_for("users.reset_token", token=token, _external=True),
        support_url=url_for("main.index"),
        operating_system="linux",
        browser_name="firefox",
    )
    msg_html = render_template(
        "users/password-reset/content.html",
        name=user.username,
        action_url=url_for("users.reset_token", token=token, _external=True),
        support_url=url_for("main.index"),
        operating_system="linux",
        browser_name="firefox",
    )
    msg = Message("Password Reset Request",
                  sender="*****@*****.**",
                  recipients=[user.email])
    msg.body = msg_text
    msg.html = msg_html
    mail.send(msg)
Exemplo n.º 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 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)
Exemplo n.º 3
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset request',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = """ To reset your password visit the following link: {} . If you did not make this request then simply ignore this email and no changes will be made.""".format(
        url_for('users.reset_token', token=token, _external=True))
    mail.send(msg)
Exemplo n.º 4
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request', recipients=[user.email])
    msg.body = f'''To reset your password, pleas visit the following link:
{url_for('users.reset_token', token=token, _external=True)}

If you didn't request a password reset, ignore this email.
'''
    mail.send(msg)
Exemplo n.º 5
0
def send_reset_email(user):
    token = user.get_reset_token()
    message = Message('Password Reset',
                      sender='*****@*****.**',
                      recipients=[user.email])
    message.body = f'''To reset your password, please visit the following link:
{url_for('reset_token', token=token, _external=True)}
'''
    mail.send(message)
Exemplo n.º 6
0
    def register_mission_v1_1():
        user = session['user']

        parsed_json = request.get_json()

        for _key in [
                "area", "description", "title", "starts_at", "ends_at", "type"
        ]:
            if _key not in parsed_json.keys():
                dict_local = {'message': "No {0} attribute.".format(_key)}
                return_string = json.dumps(dict_local,
                                           sort_keys=True,
                                           indent=4,
                                           separators=(',', ': '))
                return Response(return_string,
                                status=400,
                                mimetype='application/json')

        area = parsed_json["area"]
        description = parsed_json["description"]
        title = parsed_json["title"]
        commander = user['id']
        starts_at = parsed_json['starts_at']
        ends_at = parsed_json['ends_at']
        _type = parsed_json['type']

        mission_id = str(uuid.uuid4())
        # mission_id = "e4ca934d-988d-4a45-9139-c719dcfb491a"
        mission = Mission_DBModel(mission_id, title, commander, area,
                                  description, starts_at, ends_at, _type)
        db.session.add(mission)

        gov_offs = User_DBModel.query.filter(
            User_DBModel.account_type == 'government_official').all()

        for gov_off in gov_offs:
            #send hunnicutt an email saying that it worked!
            msg = Message('[ICARUS] Drone Mission Registered',
                          sender='*****@*****.**',
                          recipients=[gov_off.email])
            msg.body = "A mission has been created by {0}.\n\n ".format(
                user['name'])
            msg.body += "This mission stars at: {0}\n".format(starts_at)
            msg.body += "this mission ends at: {0}\"\n".format(ends_at)
            msg.body += "Check the mission at: icarusmap.com"
            print(msg)
            mail.send(msg)

        db.session.commit()
        dict_local = {'mission_id': mission_id}
        return_string = json.dumps(dict_local,
                                   sort_keys=True,
                                   indent=4,
                                   separators=(',', ': '))
        return return_string
Exemplo n.º 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 make this request then simply ignore email.
    '''
    mail.send(msg)
Exemplo n.º 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 make this request then simply ingore this email and no changes will be made.
'''
    mail.send(msg)
Exemplo n.º 9
0
def send_reset_email(user, received_token):
    token = received_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.
    '''
    print(msg)
    mail.send(msg)
Exemplo n.º 10
0
def sendemail_auth(newuser):

    token = newuser.get_auth_token_email()  # generate unique token
    msg = Message('Account Registration',  # subject
                  sender='*****@*****.**',  # sender (from)
                  recipients=[newuser.email])  # recipient (to)
    msg.body = f'''Verify account registration:
{url_for('users.auth_token', token=token, _external=True)}

If you did not make this request, then ignore this email and no actions will be taken.
'''
    mail.send(msg)  # send email
Exemplo n.º 11
0
def sendemail_emailreset(new_email):

    token = new_email.get_auth_token_email()  # generate unique token
    msg = Message('Email Reset Request',  # subject
                  sender='*****@*****.**',  # sender (from)
                  recipients=[new_email.temp_email])  # recipient (to)
    msg.body = f'''Confirm request to update email:
{url_for('users.reset_token_email', token=token, _external=True)}

If you did not make this request, then ignore this email and no changes will be taken.
'''
    mail.send(msg)  # send email
Exemplo n.º 12
0
def sendemail_pwreset(user):

    token = user.get_reset_token_pw()  # generate unique token
    msg = Message('Password Reset Request',  # subject
                  sender='*****@*****.**',  # sender (from)
                  recipients=[user.email])  # recipient (to)
    msg.body = f'''Reset password:
{url_for('users.reset_token_pw', token=token, _external=True)}

If you did not make this request, then ignore this email and no changes will be made.
'''
    mail.send(msg)  # send email
Exemplo n.º 13
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender='*****@*****.**',
                  recipients=[user.email])

    msg.body = ''' To reset your password, visit the following link:
    {}
    
    If you did not make this request then please ignore this email and no change will be made.
    '''.format({url_for('reset_token', token=token, _external=True)})

    mail.send(msg)
Exemplo n.º 14
0
def register_mail_activate(user, received_token):
    token = received_token
    try:
        msg = Message('Account activation Request',
                      sender='*****@*****.**',
                      recipients=[user.email])
        msg.body = f'''To activate your account, visit the following link:
        {url_for('register_activate', 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)
    except jwt.ExpiredSignatureError:
        pass
    return token
Exemplo n.º 15
0
def send_contact_us_email(**data):
    """It will send an email with name, email, subject and message filled by our user on contact us page to ourselves.
    """
    mail_file = os.path.join(APP_PATH, "templates", "main", "contact-us",
                             "content.txt")
    with open(mail_file, "r") as f:
        msg_text = f.read()
    msg_text = msg_text.format(**data)
    msg_html = render_template("main/contact-us/content.html", **data)
    msg = Message(data["subject"],
                  sender="*****@*****.**",
                  recipients=["*****@*****.**"])
    msg.body = msg_text
    msg.html = msg_html
    mail.send(msg)
Exemplo n.º 16
0
def send_contact_us_receipt_email(**data):
    """
    It will send an email to the user who has submitted his message on contact us page,
    stating SetNow has recieved your email.
    """
    mail_file = os.path.join(APP_PATH, "templates", "main",
                             "contact-us-receipt", "content.txt")
    with open(mail_file, "r") as f:
        msg_text = f.read()
    msg_html = render_template("main/contact-us-receipt/content.html")
    msg = Message(
        f'[SetNow Support] Re: {data["subject"]}',
        sender="*****@*****.**",
        recipients=[data["email"]],
    )
    msg.body = msg_text
    msg.html = msg_html
    mail.send(msg)
Exemplo n.º 17
0
def email_pdf(examiner, user, paper):
    mail_file = os.path.join(APP_PATH, "templates", "papers",
                             "pdf-email-receipt", "content.txt")
    with open(mail_file, "r") as f:
        msg_text = f.read()

    msg_text = msg_text.format(exam=paper.name, date=paper.exam_date)
    msg_html = render_template("papers/pdf-email-receipt/content.html",
                               exam=paper.name,
                               date=paper.exam_date)
    msg = Message(f"Paper for {paper.name}",
                  sender="*****@*****.**",
                  recipients=[examiner, user])
    msg.body = msg_text
    msg.html = msg_html

    filename, html, css = render_paper(paper)
    pdf = html.write_pdf(stylesheets=[css])
    msg.attach(filename, "application/pdf", pdf)
    mail.send(msg)
Exemplo n.º 18
0
# coding: utf-8

import sys

sys.path.append('..')
from flaskapp.sproxy.nexmo_proxy import nexmo_proxy
from flaskapp import app, mail
from flask_mail import Message

with app.app_context():
    balance = nexmo_proxy().get_balance()
    if balance <= app.config.get("PROXY_BALANCE_THRESHOLD", 1000):
        app.logger.info("WARNING, NEXMO PROXY WITH LOW BALANCE! Balance: %s" %
                        balance)
        msg = Message(
            "WARNING, NEXMO PROXY WITH LOW BALANCE!", ["*****@*****.**"],
            "WARNING, NEXMO PROXY WITH LOW BALANCE! Balance: %s" % balance)
        mail.send(msg)
Exemplo n.º 19
0
def send_email(to, subject, template):
    msg = Message(subject,
                  recipients=[to],
                  html=template,
                  sender=current_app.config['MAIL_DEFAULT_SENDER'])
    mail.send(msg)
Exemplo n.º 20
0
def send_async_email(app, msg):
    with app.app_context():
        logger.info("Email Send To " + str(msg.recipients) +
                    " Start!!! Title : " + msg.subject)
        mail.send(msg)