Пример #1
0
def invite():
    if not 'username' in session:
        return redirect(url_for('users.login'))
    email = request.form.get('email')
    message = Message('invitation to join the smartmind blog',
                      recipients=[email])
    message.html = """
    <h1>hello {{email}}<h1>
    <p>you are invited to join smartmind blog feel free to share your knowledge
    with others.You can respond to questions from other people and if you have some burning questions you can
    drop them.
    click {{link}} to join this active blog
    </p>

    """
    try:
        mail.send(message)
        flash(
            'you have successfully invited {0} to join sharp mind blog'.format(
                email), 'success')
        return redirect(url_for('users.home'))
    except:
        flash('mail not send please check your connection and try again',
              'danger')
        return redirect(url_for('users.home'))
Пример #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)
def send_async_email(subject, recipient, text_body, html_body):
    """Sends an Email"""
    from flask import current_app as app
    with app.app_context():
        msg = Message(subject=subject, recipients=[recipient])
        msg.body = text_body
        msg.html = html_body

        if not app.config.get("DEBUG") and (not app.config.get("TESTING")):
            mail.send(msg)  # pragma: no cover
Пример #4
0
def sendMail(name, email, password):
    if email and password:
        msg = Message("Nucleo Medico", recipients=[email])

        msg.html = """
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr style="background-color: #2780E3;">
                <td>
                    <table>
                        <tr>
                            <td>
                                <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Wiki_Project_Med_Foundation_logo.svg/800px-Wiki_Project_Med_Foundation_logo.svg.png"
                                    alt="VaraS de Esculapio" width="42" style="padding: 5px;">
                            </td>
                            <td style="vertical-align: middle; height: 42px;">
                                <span style="color:azure; padding: 5px;">Nucleo Medico</span>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="center" style="background-color: #eeeeee;">
                    <table border="0" cellpadding="0" cellspacing="0" width="80%" style="margin: 15px; background-color: white; padding: 10px 15px;">
                        <tr>
                            <td>
                                <p>Hola, """ + name + """:</p>
                            </td>
                        </tr>
                        <tr>
                            <td style="color: #757575; padding: 0 10px;">
                                <p>Se te a invitado a colaborar con el doctor """ + session[
            'name'] + """, en su farmacia.</p>
                                <p>Tu usuario es tu correo electronico. Su contrase&ntilde;a sera provisional solo para su primer ingreso, no la comparta con nadie, en ningun momento.</p>
                                <p style="color: #01579b; padding-left: 15px;">""" + password + """</p>
                            </td>
                        </tr>
                        <tr>
                            <td style="color: #757575;">
                                <br>
                                <br>
                                <p style="font-size: x-small;">El contenido de este email es totalmente privado no se debe ser compartido con nadie en ningun momento.</p>
                            </td>
                    </table>
                </td>
            </tr>
        </table>
        """

        try:
            mail.send(msg)
        except Exception as identifier:
            return str(identifier)

    return redirect(url_for('employees.employees'))
Пример #5
0
def send_reset_email(account):
    token = account.get_token(300)
    msg = Message('Password Reset for Zendesk Product Security Challenge',
                  sender='*****@*****.**',
                  recipients=[account.email])
    msg.body = f'''Please click on this link to reset your password:
{url_for('reset_pwd', token=token, _external=True)}

You can ignore this email if you did not request to reset your password.
'''
    mail.send(msg)
Пример #6
0
def send_pw_reset_email(user):
    token = user.get_reset_token()
    message = Message('YouBlog: Password Reset',
                      sender=os.environ['SERVER_EMAIL'],
                      recipients=[user.email])
    message.body = f'''To reset your password, visit the following link:
{url_for('users.pw_reset', token=token, _external=True)}

If you did not make this request then ignore this email, no changes will be made. 
'''
    mail.send(message)
Пример #7
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = Message('Сбросить пароль',
                  sender='*****@*****.**',
                  recipients=[user.email])
    msg.body = f'''Для восстановления пароля перейдите по ссылке ниже:
{url_for('users.reset_token', token=token, _external=True)}

Если вы не меняли пароль, просто проигнорируйте это сообщение.
'''
    mail.send(msg)
def send_password(password, email):

    recipient = email
    sender = default_email()
    token = urlSTS.dumps(recipient, salt='password-confirm')
    msg = Message('Reset Password', sender=sender, recipients=[recipient])
    msg.html = render_template('email/change_password.html',
                               user=current_user,
                               password=password)
    mail.send(msg)
    print('send_password')
    flash(f'Password sent to your email.', 'success')
    return redirect(url_for('login'))
Пример #9
0
def send_lock_email(account):
    if account.locked:
        token = account.get_token(86400)
        msg = Message('ACCOUNT LOCK OUT',
                      sender='*****@*****.**',
                      recipients=[account.email])
        msg.body = f'''You have been locked out of your account due to security issues. Please click this link to unlock your account:
    {url_for('unlock_account', token=token, _external=True)}

    The link above will expire in 24 hours. If you missed this email, please click the link below to request a new valid link:
    {url_for('request_unlock_email', _external=True)}
    '''
        mail.send(msg)
Пример #10
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)
    """

    print("SENDING RESET PASSWORD INSTRUCTION THRU EMAIL \n\n")
    print("DON'T FORGET THE OTP AS WELL! \n\n")
    otp = generateOTP()
    print(otp)
    payload = {
        'username': user['username'],
        'email': user['email'],
        'userid': user['id'],
        'propic': user['image_file'],
        'OTP': otp
    }

    print("THIS IS USER:"******"THIS IS TOKEN\n\n")
    print(access_token)

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

    print("ACHTUNG! THIS IS MESSAGE!\n")
    # print(msg)
    # print("this is message body\n")
    # print(msg.body)

    msg.body = f'''To reset your password, enter the following OTP on reset pasword form:
    {otp}
If you did not make this request then simply ignore this email and no changes will be made.
'''
    print("UPDATED MESSAGE SI: \n\n")
    print(msg)
    mail.send(msg)

    return payload
Пример #11
0
def send_mail(email_ids, sub, message_text, html_file=None, html_payload=None):
    if html_file:
        html_message = render_template(html_file, **html_payload)
        msg = Message(subject=sub,
                      body=message_text,
                      html=html_message,
                      sender=application.config['MAIL_DEFAULT_SENDER'],
                      recipients=email_ids)

    else:
        msg = Message(subject=sub,
                      body=message_text,
                      sender=application.config['MAIL_DEFAULT_SENDER'],
                      recipients=email_ids)
    mail.send(msg)
Пример #12
0
def inform():
    user = User.query.filter_by().all()
    if request.method == 'GET':
        return render_template('admin/email.html', user=user)

    else:
        title = request.form.get('title')
        email = request.form.get('email')
        recepient = request.form.get('recepient')

        message = Message(subject=title, recipients=[recepient])
        message.html = email
        mail.send(message=message)
        flash('mail send', success)
        return redirect(url_for('admin.infom'))
def purchase_confirmation(invoice, amount, customer_email):

    recipient = recipient_email()
    admin = admin_email()
    sender = default_email()
    token = urlSTS.dumps(recipient, salt='purchase-confirm')
    msg = Message('Greesha - Payment Successful',
                  sender=sender,
                  recipients=[recipient, admin])
    msg.html = render_template('email/purchase.html',
                               user=current_user,
                               invoice=invoice,
                               amount=amount,
                               customer_email=customer_email)
    mail.send(msg)
Пример #14
0
def send_email(subject,
               sender,
               recipients,
               text_body,
               attachments=None,
               sync=False):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    if attachments:
        for attachment in attachments:
            msg.attach(*attachment)
    if sync:
        mail.send(msg)
    else:
        Thread(target=send_async_email,
               args=(current_app._get_current_object(), msg)).start()
def confirm_account():

    recipient = recipient_email()
    admin = admin_email()
    sender = default_email()
    token = urlSTS.dumps(recipient, salt='email-confirm')
    msg = Message('Confirm Your Account',
                  sender=sender,
                  recipients=[recipient])
    link = url_for('confirm_email', token=token, _external=True)
    msg.html = render_template('email/layout.html',
                               user=current_user,
                               url=link)
    mail.send(msg)
    # send_async_email(app, msg)
    session['email'] = True
    return redirect(url_for('customer_profile'))
Пример #16
0
def send_email(body, emailid):
    try:
        ADMINS = config_email()
        mail.connect()
    except Exception as e:
        Error(111, str(e))

    RECP = [emailid]
    msg = Message(subject="Open conversations",
                  body=body,
                  sender=ADMINS[0],
                  recipients=RECP)

    try:
        mail.send(msg)
    except Exception as e:
        Error(500, str(e))
Пример #17
0
def send_reset_email(user):
    token = user.generate_token(user.id).decode("utf-8")
    reset_url = f'''localhost:3000/reset-password/{token}'''
    msg = Message('Password Reset Request',
                  sender=current_app.config.get('MAIL_USERNAME'),
                  recipients=[user.email])
    msg.html = render_template('reset.html', link=reset_url)

    mail.send(msg)


# def send_access_granted_email():
#
#     msg = Message('Password Reset Request',
#                   sender=current_app.config.get('MAIL_USERNAME'),
#                   recipients=[user.email])
#     msg.html = render_template('reset.html', link=reset_url)
#
#     mail.send(msg)
Пример #18
0
def contact():
    form = ContactForm()

    if request.method == 'POST':
        if form.validate() == False:
            flash('Alle feltene må fylles ut.')
            return render_template('contact.html', form=form)
        else:
            msg = Message(form.subject.data,
                          sender='*****@*****.**',
                          recipients=['*****@*****.**'])
            msg.body = """
            Fra: %s, %s;
            
            %s
            """ % (form.name.data, form.email.data, form.message.data)
            mail.send(msg)
            return render_template('contact.html', success=True)

    elif request.method == 'GET':
        return render_template('contact.html', form=form)
Пример #19
0
def send_email(subject, sender, recipients, text_body, html_body):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    with app.app_context():
        mail.send(msg)
Пример #20
0
def send_contact_email(name, email, msg):
    message = Message(f'Message from {name}', sender=email, recipients=[os.environ['SERVER_EMAIL']])
    message.body = msg + f'\nReply email address: {email}'
    mail.send(message)
    
def send_async_email(app, msg):
    with app.app_context():
        mail.send(msg)
Пример #22
0
def send_sync_email(instance, msg):
    with instance.app_context():
        mail.send(msg)
Пример #23
0
def send_async_email(msg):
    """Send generic email using threaded approach."""
    with app.app_context():
        mail.send(msg)