Beispiel #1
0
def document_send(doc_id):
    doc = get_document(doc_id)

    recipient = request.form.get("recipient")
    user_msg = request.form.get("message")

    site_name = "[{}] ".format(current_app.config["SITE_NAME"])
    sender_name = current_user.name
    subject = site_name + _("{sender} sent you a file").format(
        sender=sender_name)
    msg = Message(subject)
    msg.sender = current_user.email
    msg.recipients = [recipient]
    msg.body = render_template_i18n(
        "documents/mail_file_sent.txt",
        sender_name=sender_name,
        message=user_msg,
        document_url=url_for(doc),
        filename=doc.title,
    )

    filename = doc.title
    msg.attach(filename, doc.content_type, doc.content)

    mail.send(msg)
    flash(_("Email successfully sent"), "success")

    return redirect(url_for(doc))
Beispiel #2
0
def document_send(doc_id):
    doc = get_document(doc_id)

    recipient = request.form.get("recipient")
    user_msg = request.form.get("message")

    site_name = "[{}] ".format(current_app.config["SITE_NAME"])
    sender_name = current_user.name
    subject = site_name + _("{sender} sent you a file").format(sender=sender_name)
    msg = Message(subject)
    msg.sender = current_user.email
    msg.recipients = [recipient]
    msg.body = render_template_i18n(
        "documents/mail_file_sent.txt",
        sender_name=sender_name,
        message=user_msg,
        document_url=url_for(doc),
        filename=doc.title,
    )

    filename = doc.title
    msg.attach(filename, doc.content_type, doc.content)

    mail.send(msg)
    flash(_("Email successfully sent"), "success")

    return redirect(url_for(doc))
Beispiel #3
0
def send_application_by_email(application):
    recipients = app.config.get('SDC_RECIPIENTS')
    body = render_template("sdc/email.txt", proposal=application)
    msg = Message("New application to the student demo cup",
                  body=body,
                  sender="*****@*****.**",
                  recipients=recipients)
    mail.send(msg)
Beispiel #4
0
def send_post_to_user(community, post, member):
    recipient = member.email
    subject = f"[{community.name}] {post.title}"

    config = current_app.config
    SENDER = config.get("BULK_MAIL_SENDER", config["MAIL_SENDER"])
    SBE_FORUM_REPLY_BY_MAIL = config.get("SBE_FORUM_REPLY_BY_MAIL", False)
    SBE_FORUM_REPLY_ADDRESS = config.get("SBE_FORUM_REPLY_ADDRESS", SENDER)
    SERVER_NAME = config.get("SERVER_NAME", "example.com")

    list_id = '"{} forum" <forum.{}.{}>'.format(
        community.name, community.slug, SERVER_NAME
    )
    forum_url = url_for("forum.index", community_id=community.slug, _external=True)
    forum_archive_url = url_for(
        "forum.archives", community_id=community.slug, _external=True
    )
    extra_headers = {
        "List-Id": list_id,
        "List-Archive": f"<{forum_archive_url}>",
        "List-Post": f"<{forum_url}>",
        "X-Auto-Response-Suppress": "All",
        "Auto-Submitted": "auto-generated",
    }

    if SBE_FORUM_REPLY_BY_MAIL:
        name = SBE_FORUM_REPLY_ADDRESS.rsplit("@", 1)[0]
        domain = SBE_FORUM_REPLY_ADDRESS.rsplit("@", 1)[1]
        replyto = build_reply_email_address(name, post, member, domain)
        msg = Message(
            subject,
            sender=SBE_FORUM_REPLY_ADDRESS,
            recipients=[recipient],
            reply_to=replyto,
            extra_headers=extra_headers,
        )
    else:
        msg = Message(
            subject, sender=SENDER, recipients=[recipient], extra_headers=extra_headers
        )

    ctx = {
        "community": community,
        "post": post,
        "member": member,
        "MAIL_REPLY_MARKER": MAIL_REPLY_MARKER,
        "SBE_FORUM_REPLY_BY_MAIL": SBE_FORUM_REPLY_BY_MAIL,
    }
    msg.body = render_template_i18n("forum/mail/new_message.txt", **ctx)
    msg.html = render_template_i18n("forum/mail/new_message.html", **ctx)
    logger.debug("Sending new post by email to %r", member.email)

    try:
        mail.send(msg)
    except BaseException:
        # log to sentry if enabled
        logger.error("Send mail to user failed", exc_info=True)
Beispiel #5
0
def send_post_to_user(community, post, member):
    recipient = member.email
    subject = "[{}] {}".format(community.name, post.title)
    config = current_app.config
    sender = config.get("BULK_MAIL_SENDER", config["MAIL_SENDER"])
    SBE_FORUM_REPLY_BY_MAIL = config.get("SBE_FORUM_REPLY_BY_MAIL", False)
    SERVER_NAME = config.get("SERVER_NAME", "example.com")
    list_id = '"{} forum" <forum.{}.{}>'.format(community.name, community.slug,
                                                SERVER_NAME)
    forum_url = url_for("forum.index",
                        community_id=community.slug,
                        _external=True)
    forum_archive = url_for("forum.archives",
                            community_id=community.slug,
                            _external=True)

    extra_headers = {
        "List-Id": list_id,
        "List-Archive": "<{}>".format(forum_archive),
        "List-Post": "<{}>".format(forum_url),
        "X-Auto-Response-Suppress": "All",
        "Auto-Submitted": "auto-generated",
    }

    if SBE_FORUM_REPLY_BY_MAIL and config["MAIL_ADDRESS_TAG_CHAR"] is not None:
        name = sender.rsplit("@", 1)[0]
        domain = sender.rsplit("@", 1)[1]
        replyto = build_reply_email_address(name, post, member, domain)
        msg = Message(
            subject,
            sender=sender,
            recipients=[recipient],
            reply_to=replyto,
            extra_headers=extra_headers,
        )
    else:
        msg = Message(subject,
                      sender=sender,
                      recipients=[recipient],
                      extra_headers=extra_headers)

    ctx = {
        "community": community,
        "post": post,
        "member": member,
        "MAIL_REPLY_MARKER": MAIL_REPLY_MARKER,
        "SBE_FORUM_REPLY_BY_MAIL": SBE_FORUM_REPLY_BY_MAIL,
    }
    msg.body = render_template_i18n("forum/mail/new_message.txt", **ctx)
    msg.html = render_template_i18n("forum/mail/new_message.html", **ctx)
    logger.debug("Sending new post by email to %r", member.email)

    try:
        mail.send(msg)
    except BaseException:
        logger.error("Send mail to user failed",
                     exc_info=True)  # log to sentry if enabled
Beispiel #6
0
def send_proposal_by_email(proposal):
  if app.config.get('TESTING'):
    recipients = ["*****@*****.**"]
  else:
    recipients = ["*****@*****.**", "*****@*****.**"]

  body = render_template("cfp/email.txt", proposal=proposal)
  msg = Message("New talk proposal for OWF 2013",
                body=body,
                sender="*****@*****.**",
                recipients=recipients)
  mail.send(msg)
Beispiel #7
0
def send_proposal_by_email(proposal):
    if app.config.get('TESTING'):
        recipients = ["*****@*****.**"]
    else:
        recipients = ["*****@*****.**", "*****@*****.**"]

    body = render_template("cfp/email.txt", proposal=proposal)
    msg = Message("New talk proposal for OWF 2013",
                  body=body,
                  sender="*****@*****.**",
                  recipients=recipients)
    mail.send(msg)
Beispiel #8
0
def send_confirmation_email(registration):
  recipients = [registration.email]
  serializer = URLSafeSerializer(app.config['SECRET_KEY'])
  token = serializer.dumps(registration.email)
  body = render_template("registration/email/confirmation_fr.txt",
                         registration=registration, token=token)
  msg = Message(
    _("Please confirm your participation at the Open World Forum 2013"),
    body=body,
    sender="*****@*****.**",
    recipients=recipients)
  print msg
  mail.send(msg)
Beispiel #9
0
def send_confirmation_email(registration):
    recipients = [registration.email]
    serializer = URLSafeSerializer(app.config['SECRET_KEY'])
    token = serializer.dumps(registration.email)
    body = render_template("registration/email/confirmation_fr.txt",
                           registration=registration,
                           token=token)
    msg = Message(
        _("Please confirm your participation at the Open World Forum 2013"),
        body=body,
        sender="*****@*****.**",
        recipients=recipients)
    print msg
    mail.send(msg)
Beispiel #10
0
def send_post_to_user(community, post, member):
    recipient = member.email
    subject = u'[%s] %s' % (community.name, post.title)
    config = current_app.config
    sender = config.get('BULK_MAIL_SENDER', config['MAIL_SENDER'])
    SBE_FORUM_REPLY_BY_MAIL = config.get('SBE_FORUM_REPLY_BY_MAIL', False)
    SERVER_NAME = config.get('SERVER_NAME', u'example.com')
    list_id = u'"{} forum" <forum.{}.{}>'.format(community.name,
                                                 community.slug, SERVER_NAME)
    forum_url = url_for('forum.index',
                        community_id=community.slug,
                        _external=True)
    forum_archive = url_for('forum.archives',
                            community_id=community.slug,
                            _external=True)

    extra_headers = {
        'List-Id': list_id,
        'List-Archive': u'<{}>'.format(forum_archive),
        'List-Post': '<{}>'.format(forum_url),
        'X-Auto-Response-Suppress': 'All',
        'Auto-Submitted': 'auto-generated',
    }

    if SBE_FORUM_REPLY_BY_MAIL and config['MAIL_ADDRESS_TAG_CHAR'] is not None:
        name = sender.rsplit('@', 1)[0]
        domain = sender.rsplit('@', 1)[1]
        replyto = build_reply_email_address(name, post, member, domain)
        msg = Message(subject,
                      sender=sender,
                      recipients=[recipient],
                      reply_to=replyto,
                      extra_headers=extra_headers)
    else:
        msg = Message(subject,
                      sender=sender,
                      recipients=[recipient],
                      extra_headers=extra_headers)

    msg.body = render_template_i18n(
        "forum/mail/new_message.txt",
        community=community,
        post=post,
        member=member,
        MAIL_REPLY_MARKER=MAIL_REPLY_MARKER,
        SBE_FORUM_REPLY_BY_MAIL=SBE_FORUM_REPLY_BY_MAIL,
    )
    msg.html = render_template_i18n(
        "forum/mail/new_message.html",
        community=community,
        post=post,
        member=member,
        MAIL_REPLY_MARKER=MAIL_REPLY_MARKER,
        SBE_FORUM_REPLY_BY_MAIL=SBE_FORUM_REPLY_BY_MAIL,
    )
    logger.debug("Sending new post by email to %r", member.email)

    try:
        mail.send(msg)
    except:
        logger.error("Send mail to user failed",
                     exc_info=True)  # log to sentry if enabled