当前位置: 首页>>代码示例>>Python>>正文


Python Message.body方法代码示例

本文整理汇总了Python中flaskext.mail.Message.body方法的典型用法代码示例。如果您正苦于以下问题:Python Message.body方法的具体用法?Python Message.body怎么用?Python Message.body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flaskext.mail.Message的用法示例。


在下文中一共展示了Message.body方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: admin_send_reminder

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def admin_send_reminder(payment_id):
    payment = BankPayment.query.get_or_404(payment_id)

    form = SendReminderForm()
    if form.validate_on_submit():
        if form.remind.data:
            app.logger.info("%s sending reminder email to %s <%s> for payment %s",
                            current_user.name, payment.user.name, payment.user.email, payment.id)

            if payment.reminder_sent:
                app.logger.error('Reminder for payment %s already sent', payment.id)
                flash("Cannot send duplicate reminder email for payment %s" % payment.id)
                return redirect(url_for('admin_expiring'))

            msg = Message("Electromagnetic Field ticket purchase update",
                          sender=app.config['TICKETS_EMAIL'],
                          recipients=[payment.user.email])
            msg.body = render_template("tickets-reminder.txt", payment=payment)
            mail.send(msg)

            payment.reminder_sent = True
            db.session.commit()

            flash("Reminder email for payment %s sent" % payment.id)
            return redirect(url_for('admin_expiring'))

    return render_template('admin/payment-send-reminder.html', payment=payment, form=form)
开发者ID:Paul2d,项目名称:Website,代码行数:29,代码来源:admin.py

示例2: send_test_email

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def send_test_email(recipient):
    mail = Mail(app)
    msg = Message("Test Message -- Candidates Emailer app",
                  [recipient],
                  sender="[email protected]")
    msg.body = "This is a test message from the Candidates Emailer App"
    mail.send(msg)
开发者ID:mkhattab,项目名称:candidates_emailer,代码行数:9,代码来源:manage.py

示例3: admin_txn_reconcile

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def admin_txn_reconcile(txn_id, payment_id):
    txn = BankTransaction.query.get_or_404(txn_id)
    payment = BankPayment.query.get_or_404(payment_id)

    form = ManualReconcilePaymentForm()
    if form.validate_on_submit():
        if form.reconcile.data:
            app.logger.info("%s manually reconciling against payment %s (%s) by %s",
                            current_user.name, payment.id, payment.bankref, payment.user.email)

            if txn.payment:
                app.logger.error("Transaction already reconciled")
                flash("Transaction %s already reconciled" % txn.id)
                return redirect(url_for('admin_txns'))

            if payment.state == 'paid':
                app.logger.error("Payment has already been paid")
                flash("Payment %s already paid" % payment.id)
                return redirect(url_for('admin_txns'))

            txn.payment = payment
            payment.paid()
            db.session.commit()

            msg = Message("Electromagnetic Field ticket purchase update",
                          sender=app.config['TICKETS_EMAIL'],
                          recipients=[payment.user.email])
            msg.body = render_template("tickets-paid-email-banktransfer.txt",
                          user=payment.user, payment=payment)
            mail.send(msg)

            flash("Payment ID %s marked as paid" % payment.id)
            return redirect(url_for('admin_txns'))

    return render_template('admin/txn-reconcile.html', txn=txn, payment=payment, form=form)
开发者ID:Paul2d,项目名称:Website,代码行数:37,代码来源:admin.py

示例4: register

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def register(year, eventname):
    form = RegisterForm()
    event = Event.query.filter_by(name=eventname, year=year).first()
    if form.validate_on_submit():
        participant = Participant()
        form.populate_obj(participant)
        participant.event_id = event.id
        participant.ipaddr = request.environ["REMOTE_ADDR"]
        participant.useragent = request.user_agent.string
        participant.email_key = uuid4().hex
        db.session.add(participant)
        db.session.commit()
        if not participant.email_sent:
            msg = Message(subject="Geekup Confirmation", recipients=[participant.email])
            msg.body = render_template("confirmemail.md", participant=participant)
            msg.html = markdown(msg.body)
            mail.send(msg)
            participant.email_sent = True
            db.session.commit()
        return render_template("regsuccess.html")
    else:
        if request.is_xhr:
            return render_template("regform.html", regform=form, ajax_re_register=True)
        else:
            flash("Please check your details and try again.", "error")
            return eventpage(eventname, regform=form)
开发者ID:geohacker,项目名称:geekup,代码行数:28,代码来源:user.py

示例5: notify

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def notify(data,d):
    if not 'epdoc' in data: return
    m=db.notifications.find({'dossiers': data['epdoc']},['active_emails'])
    for g in m:
        if len(g['active_emails'])==0:
            continue
        msg = Message("[PT-Com] %s: %s" %
                      (data['committee'],
                       data['title']),
                      sender = "[email protected]",
                      bcc = g['active_emails'])
        msg.body = (u"Parltrack has detected %s%s on the schedule of %s \n"
                    u"\n  on %s"
                    u"\n%s"
                    u"%s"
                    u"\nsee the details here: %s\n"
                    u"\nYour Parltrack team" %
                    (u"a change on " if d else u'',
                     data['epdoc'],
                     data['committee'],
                     data['date'] if 'date' in data else 'unknown date',
                     ("\n  - %s" % u'\n  - '.join(data['list'])) if 'list' in data and len(data['list'])>0 else u"",
                     "\n %s" % (textdiff(d) if d else ''),
                     "%s/dossier/%s" % (ROOT_URL, data['epdoc']),
                    ))
        mail.send(msg)
开发者ID:asciimoo,项目名称:parltrack,代码行数:28,代码来源:ep_comagendas.py

示例6: send_notify

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def send_notify(notify_type, data, status=NOT_PROCESSES):
    """
    Отсылает администации уведомления о каких-либо событиях.
    В админку всегда, а на почту.
    """

    # пока поддреживаем только один тип нотификаций (о новых видосах)
    if notify_type != 0:
        raise NotImplemented(u'%s notify does not support yet')

    # notice = app.connection.Notice()
    # notice.update({'notice_type': notify_type, 'data': data, 'status': status})
    # notice.save()

    if not Message or not mail or status != NOT_PROCESSES: return
    
    msg = Message(u'Новое видео', recipients=app.config['ADMINS'])
    msg.html = u"""
    <p>Пользователь %(username)s добавил новое видео по трюку %(trickname)s:</p>
    <a href="%(video_url)s" target="_blank">%(video_url)s</a>
    <p>Отмодерировать это дело можно в админке: <a href="%(admin_url)s" target="_blank">%(admin_url)s</a></a>
    """ % {
        'username'  : app.db.user.find_one({"_id": data["user"]})['nick'],
        'trickname' : data['trickname'],
        'video_url' : data['video_url'],
        'admin_url' : app.config['HOST'] + '/#admin/videos/'
    }
    msg.body = ""

    mail.send(msg)
开发者ID:zerc,项目名称:besttrick.ru,代码行数:32,代码来源:notify.py

示例7: signup

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def signup():
    if current_user.is_authenticated():
        return redirect(url_for('tickets'))
    form = SignupForm(request.form, next=request.args.get('next'))

    if request.method == 'POST' and form.validate():
        user = User(form.email.data, form.name.data)
        user.set_password(form.password.data)
        db.session.add(user)
        try:
            db.session.commit()
        except IntegrityError, e:
            app.logger.warn('Adding user raised %r, assuming duplicate email', e)
            flash("This email address %s is already in use. Please log in, or reset your password if you've forgotten it." % (form.email.data))
            return redirect(url_for('login'))
        login_user(user)

        # send a welcome email.
        msg = Message("Welcome to Electromagnetic Field",
                sender=app.config['TICKETS_EMAIL'],
                recipients=[user.email])
        msg.body = render_template("welcome-email.txt", user=user)
        mail.send(msg)

        return redirect(form.next.data or url_for('tickets'))
开发者ID:Jonty,项目名称:Website,代码行数:27,代码来源:users.py

示例8: notification_add_detail

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def notification_add_detail(g_id, item, value):
    db = connect_db()
    group = db.notifications.find_one({'id': g_id})
    if not group:
        return 'unknown group '+g_id
    # TODO handle restricted groups
    #if group.restricted:
    #    return 'restricted group'
    if item == 'emails':
        if value in group['active_emails']:
            return 'already subscribed to this group'
        item = 'actions'
        # TODO validation
        addr = db.notifications.find_one({'actions.address': value, 'id': g_id})
        if addr:
            # or just return with OK?! -> more privacy but harder debug
            return 'Already subscribed'
        i = {'address': value, 'type': 'subscription', 'token': sha1(''.join([chr(randint(32, 122)) for x in range(12)])).hexdigest(), 'date': datetime.now()}
        msg = Message("Parltrack Notification Subscription Verification",
                sender = "[email protected]",
                recipients = [value])
        msg.body = "Your verification key is %sactivate?key=%s\nNotification group url: %snotification/%s" % (request.url_root, i['token'], request.url_root, g_id)
        mail.send(msg)

    else:
        #if db.notifications.find({'dossiers': value}).count():
        #    return 'OK'
        i = db.dossiers.find_one({'procedure.reference': value})
        if not i:
            return 'unknown dossier - '+value
        i = i['procedure']['reference']

    group[item].append(i)
    db.notifications.save(group)
    return 'OK'
开发者ID:JacobOscarson,项目名称:parltrack,代码行数:37,代码来源:webapp.py

示例9: warn_admin

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def warn_admin(req, mail):
    """
    emails the request information to the admin
    """
    message = {
            "subject": "WARNING: Bot attempted to access email form",
            "sender": "[email protected]",
            }
    msg = Message(message['subject'], sender=message['sender'],
            recipients=['[email protected]'])

    message['message'] =\
            """
A wannabe cracker (or loose bot) fell for the honeypot. Here are the
details from the req:\n
%(req)s 
            """ % {
                    "req": req,
                }
    msg.body = message['message']
    try:
        mail.send(msg)
        ret = dict(msg=msg,
                succ_code=0)
    except:
        ret = dict(msg=msg,
                succ_code=1)
    return ret
开发者ID:LBConsulting,项目名称:mrna,代码行数:30,代码来源:views.py

示例10: send_awaiting_confirm_mail

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def send_awaiting_confirm_mail(user):
  
    subject = "We're waiting for your confirmation!!"
    mail_to_be_sent = Message(subject=subject, recipients=[user['Members_Email']])
    confirmation_url = url_for('activate_user', user_id=user['_id'],
_external=True)
    mail_to_be_sent.body = "Dear %s, click here to confirm: %s" %
开发者ID:TechQuity,项目名称:milk2,代码行数:9,代码来源:mailing.py

示例11: mark_complete

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def mark_complete():
    """
    Checks to see if a group exists in FAS for the given project and marks the
    project complete if it does. We do this this way so that we don't have to
    send FAS credentials to this app.
    """
    fas = fedora.client.AccountSystem(app.config['FAS_SERVER'],
                                      username=app.config['FAS_USERNAME'],
                                      password=app.config['FAS_PASSWORD'],
                                      insecure=app.config['FAS_INSECURE_SSL'])
    hosted_request = HostedRequest.query.filter_by(id=request.args.get('id'))
    if hosted_request.count() > 0:
        project = hosted_request[0]
        if project.completed:
            return jsonify(error="Request was already marked as completed.")

        group_name = project.scm + project.name
        try:
            group = fas.group_by_name(group_name)
        except:
            return jsonify(error="No such group: " + group_name)

        project.completed = datetime.now()
        db.session.commit()
        message = Message("Your Fedora Hosted request has been processed")
        message.body = """Hi there,

You're receiving this message because the Fedora Hosted project:
  %s
has been set up.

To access to your new repository, do the following:
  $ %s

If you've requested a Trac instance, you can visit it at:
  https://fedorahosted.org/%s

If you've requested any mailing lists, you should have received separate
emails which contain instructions on how to administrate them.

Sincerely,
Fedora Hosted""" % (
            project.name,
            scm_push_instructions(project),
            project.name)

        message.sender = \
            "Fedora Hosted <[email protected]>"

        if 'PROJECT_OWNER_EMAIL_OVERRIDE' in app.config:
            message.recipients = [app.config['PROJECT_OWNER_EMAIL_OVERRIDE']]
        else:
            message.recipients = ["%[email protected]" % project.owner]

        if not app.config['TESTING']:
            mail.send(message)

        return jsonify(success="Request marked as completed.")
    else:
        return jsonify(error="No hosted request with that ID could be found.")
开发者ID:relrod,项目名称:fedorahosted,代码行数:62,代码来源:main.py

示例12: post

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
    def post(self):
        if request.json:
            try:
                email = request.json['email']
            except IndexError, e:
                return self.send_400("%s is required" % e)
            try:
                user = User.select(User.q.email==email)[0]
            except:
                return self.send_200({"success": True})
            token = ResetToken(user=user)
            msg = Message("Password Reset",
                          sender=(SITE_NAME, "[email protected]%s" % SITE_URL),
                          recipients=[email])
            message = """
            Hello!
            You (hopefully) have requested a password reset for your account at
            {site_name}. In order to complete this reset, please visit:

            {site_url}/reset/?{enc_token}
            """

            msg.body = message.format(site_name=SITE_NAME, site_url=SITE_URL,
                                      enc_token=quote(token.token))
            g.mail.send(msg)
开发者ID:philippeowagner,项目名称:beerlogjs,代码行数:27,代码来源:admin.py

示例13: sendmail

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def sendmail():
    task = Task.query.order_by(Task.created).first()
    msg = Message("Get things done!",
                  sender=("GTD", "[email protected]"),
                  recipients=["[email protected]"])
    if not task:
        return
    msg.body = "Hey,\n how about doing '" + task.title + "'?\n"
    msg.body += "It has been waiting for " + task.waited_text()
    if task.postponed_count > 0:
        msg.body += " and you have postponed it "
        msg.body += str(task.postponed_count) + " already"
    msg.body += ".\n"
    msg.body += "Here is some more information:\n"
    if len(task.desc.strip()) > 0:
        msg.body += "Description: " + task.desc_text() + "\n"
    if task.tags != "":
        msg.body += "Tags: " + task.tags + "\n"
    if task.due_text():
        msg.body += "Due: " + task.due_text() + "\n"
    if task.duration_text():
        msg.body += "Duration: " + task.duration_text() + "\n"
    if len(task.text.strip()) > 0:
        msg.body += "Text:\n" + task.text + "\n"
    msg.body += "\nMark task done: " + conf.SITE_URL + "do/" + str(task.id)+"/\n"
    msg.body += "Postpone to later: " + conf.SITE_URL + "postpone/" + str(task.id) + "/"
    mail.send(msg)
开发者ID:jmtoball,项目名称:gtfd,代码行数:29,代码来源:manage.py

示例14: notification_del_detail

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def notification_del_detail(g_id, item, value):
    db = connect_db()
    group = db.notifications.find_one({"id": g_id})
    if not group:
        return "unknown group " + g_id
    # TODO handle restricted groups
    # if group.restricted:
    #    return 'restricted group'
    if item == "emails":
        print value
        print group["active_emails"]
        if value not in group["active_emails"]:
            return "Cannot complete this action"
        i = {
            "address": value,
            "type": "unsubscription",
            "token": sha1("".join([chr(randint(32, 122)) for x in range(12)])).hexdigest(),
            "date": datetime.now(),
        }
        group["actions"].append(i)
        msg = Message(
            "Parltrack Notification Unsubscription Verification",
            sender="[email protected]",
            recipients=[value],
        )
        msg.body = "Your verification key is %sactivate?key=%s\nNotification group url: %snotification/%s" % (
            request.url_root,
            i["token"],
            request.url_root,
            g_id,
        )
        mail.send(msg)
        db.notifications.save(group)
    return "OK"
开发者ID:tttp,项目名称:parltrack,代码行数:36,代码来源:webapp.py

示例15: confirm

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import body [as 别名]
def confirm(hashid):
    post = JobPost.query.filter_by(hashid=hashid).first()
    form = forms.ConfirmForm()
    if post is None:
        abort(404)
    elif post.status == POSTSTATUS.REJECTED:
        abort(410)
    elif post.status == POSTSTATUS.DRAFT:
        if post.edit_key not in session.get('userkeys', []):
            abort(403)
    else:
        # Any other status: no confirmation required (via this handler)
        return redirect(url_for('jobdetail', hashid=post.hashid), code=302)
    if 'form.id' in request.form and form.validate_on_submit():
        # User has accepted terms of service. Now send email and/or wait for payment
        if not post.email_sent:
            msg = Message(subject="Confirmation of your job listing at the HasGeek Job Board",
                recipients=[post.email])
            msg.body = render_template("confirm_email.md", post=post)
            msg.html = markdown(msg.body)
            mail.send(msg)
            post.email_sent = True
            post.status = POSTSTATUS.PENDING
            db.session.commit()
        session.get('userkeys', []).remove(post.edit_key)
        session.modified = True # Since it won't detect changes to lists
        session.permanent = True
        return render_template('mailsent.html', post=post)
    return render_template('confirm.html', post=post, form=form)
开发者ID:kracekumar,项目名称:hasjob,代码行数:31,代码来源:views.py


注:本文中的flaskext.mail.Message.body方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。