Beispiel #1
0
def send_mail(recipients, title, message, sender='*****@*****.**'):
    with mail.app.app_context():
        msg = Message(title, recipients=recipients)
        if sender:
            msg.sender = sender
        msg.html = message
        mail.send(msg)
def send_reset_password_email(password_link, recipient):
    """Creates the email with templates and sends it to the user"""
    reset_mail = Message(subject="Reset Password", recipients=[recipient.email])
    template_args = {"password_link": password_link, "recipient": recipient.username}
    reset_mail.body = render_template("password_reset.txt", **template_args)
    reset_mail.html = render_template("password_reset.html", **template_args)
    mail.send(reset_mail)
Beispiel #3
0
def send_email(subject, sender, recipients, text_body, html_body, sync=False):
    current_app.logger.debug('inside send_email')
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    if sync:
        mail.send(msg)
    else:
        Thread(target=send_async_email,
               args=[current_app._get_current_object(), msg]).start()
Beispiel #4
0
def send_email(html, redirect, recipients, subject, token):
    url = url_for(redirect, token=token, _external=True)
    template = render_template(html, url=url)
    msg = Message(
        subject=subject,
        recipients=[recipients],
        html=template,
        sender=current_app.config.get("MAIL_DEFAULT_SENDER")
    )
    mail.send(msg)
Beispiel #5
0
def send_mail(recipients, title, message, sender='*****@*****.**', cc=None):
    from flask_mail import Message
    from application.extensions import mail

    msg = Message(title, recipients=recipients)
    if sender:
        msg.sender = sender
    if cc:
        msg.cc=cc
    msg.html = message
    mail.send(msg)
    return True
def _send_feedback_email(feedback, request_by, request_from):

    msg = Message(
        html=render_template(
            'feedback/email/feedback-request.html',
            sender=request_by,
            recipient=request_from,
            url=url_for('.reply_to_feedback', id=feedback.id, _external=True)),
        subject="Feedback request from {name}".format(
            name=request_by.full_name),
        sender="*****@*****.**",
        recipients=[feedback.entry.requested_from])

    try:
        mail.send(msg)

    except Exception as e:
        current_app.logger.error("failed to send email", e)
        abort(500)

    feedback.entry.update(sent=True)
def _send_feedback_email(feedback, request_by, request_from):
    host = current_app.config['HOST']
    if 'localhost' in host:
        host = "%s:8000" % host
    url = "http://%s/give-feedback/%s" % (host, feedback.id)
    html = render_template('feedback/email/feedback-request.html',
                           request_by=request_by,
                           request_from=request_from,
                           url=url)
    msg = Message(html=html,
                  subject="Feedback request from test",
                  sender="*****@*****.**",
                  recipients=[feedback.entry.requested_from])
    try:
        mail.send(msg)
        feedback.entry.sent = True
        feedback.entry.save()
        feedback.save()
    except Exception as ex:
        current_app.logger.error("failed to send email", ex)
        return 'Internal Server Error', 500
Beispiel #8
0
def _send_feedback_email(feedback, request_by, request_from):

    msg = Message(html=render_template('feedback/email/feedback-request.html',
                                       sender=request_by,
                                       recipient=request_from,
                                       url=url_for('.reply_to_feedback',
                                                   id=feedback.id,
                                                   _external=True)),
                  subject="Feedback request from {name}".format(
                      name=request_by.full_name),
                  sender="*****@*****.**",
                  recipients=[feedback.entry.requested_from])

    try:
        mail.send(msg)

    except Exception as e:
        current_app.logger.error("failed to send email", e)
        abort(500)

    feedback.entry.update(sent=True)
Beispiel #9
0
def send_mail(receiver, title, content):
    msg = Message(title,
                  sender=current_app.config['MAIL_USERNAME'],
                  recipients=[receiver])
    msg.body = content
    mail.send(msg)
 def notify_email(self, email, message):
      msg = Message(message,
         recipients=[email])
      mail.send(msg)
Beispiel #11
0
def send_async_email(app, msg):
    with app.app_context():
        mail.send(msg)