Esempio n. 1
0
def send_mail(body, address, fromaddr=None, subject=None, **kwargs):
    if not isinstance(address, (list, tuple, set)):
        address = [address, ]

    from settings import mail
    from flask_mail import Message
    msg = Message(subject, sender=fromaddr, recipients=address, body = body)
    mail.send(msg)
Esempio n. 2
0
def send_mail(recipients=None, token=None):
    link = app.config['FRONT_END_URL'] + '?token=' + str(token)
    print('link\n', link)
    msg = Message("Welcome to InScholaris", recipients=[recipients])
    msg.html = render_template('verification_mail.html',
                               sending_mail=True,
                               verify_link=link)
    mail.send(msg)
Esempio n. 3
0
def send_async_email(email_data):

    """Background task to send an email with Flask-Mail."""
    with app.app_context():
        msg = Message(email_data['subject'],
                      sender=app.config['MAIL_DEFAULT_SENDER'],
                      recipients=[email_data['to']])
        msg.body = email_data['body']
        mail.send(msg)
Esempio n. 4
0
def contact():
    form = Contact(request.form)
    if request.method == 'POST' and form.validate():
        message = 'Nombre: %s\nEmail: %s\n%s' % (form.name.data,
        									form.email.data, form.text.data)
        msg = Message(subject=form.subject.data, sender=form.email.data,
        			  body=message, recipients=[''])
        mail.send(msg)
        return render_template('success.html')
    return render_template('contact-form.html',
    	form=form)
Esempio n. 5
0
def send_mail_from_translator():
    data = request.get_json()
    if current_user.is_authenticated(
    ) and not current_user.has_role('blocked'):
        translator = Translator.query.filter(
            Translator.slug == data['translator']).first()
        data['translator'] = translator.first_name + " " + translator.last_name
        data['user'] = current_user.email
        data['date'] = datetime.datetime.now()

        mail_template = render_template('service-mail.jinja', **data)

        msg = Message('new service',
                      sender="*****@*****.**",
                      recipients=["*****@*****.**"])
        msg.body = mail_template
        mail.send(msg)
        return jsonify(
            **{
                'status':
                'ok',
                'notification':
                render_template(
                    '_notification.html',
                    text=
                    "We have recived your service offer. We will contact you soon."
                )
            })
    else:
        if not current_user.is_authenticated():
            return jsonify(
                **{
                    'status':
                    'fail',
                    'notification':
                    render_template('_notification.html',
                                    text="Sorry, you are not authenticated!")
                })
        elif current_user.has_role('blocked'):
            return jsonify(
                **{
                    'status':
                    'fail',
                    'notification':
                    render_template('_notification.html',
                                    text="Sorry, you are in the blacklist!")
                })
Esempio n. 6
0
def send_mail_from_service():
    data = request.get_json()
    if current_user.is_authenticated() and not current_user.has_role('blocked'):
        service=Service.query.filter(Service.slug==data['service']).first()
        data['service'] = service.name
        data['user'] = current_user.email
        data['date'] = datetime.datetime.now()

        mail_template = render_template('service-mail.jinja', **data)

        msg = Message('new service',
                      sender="*****@*****.**",
                      recipients=["*****@*****.**"])
        msg.body = mail_template
        mail.send(msg)
        return jsonify(**{'status':'ok', 'notification': render_template('_notification.html', text="We have recived your service offer. We will contact you soon.")})
    else:
        if not current_user.is_authenticated():
            return jsonify(**{'status':'fail', 'notification': render_template('_notification.html', text="Sorry, you are not authenticated!")})
        elif current_user.has_role('blocked'):
            return jsonify(**{'status':'fail', 'notification': render_template('_notification.html', text="Sorry, you are in the blacklist!")})