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


Python Mail.send方法代码示例

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


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

示例1: send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_email(to, subject, template, **kwargs):
    mail = Mail(app)
    msg = Message(app.config['FLASKY_MAIL_SUBJECT_PREFIX'] + ' ' + subject,
                  sender=app.config['FLASKY_MAIL_SENDER'], recipients=[to])
    msg.body = render_template(template + '.txt', **kwargs)
    msg.html = render_template(template + '.html', **kwargs)
    mail.send(msg)
开发者ID:qiupengfei,项目名称:OurPlan,代码行数:9,代码来源:example.py

示例2: send_message

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_message(subject, body, html=False, caps_gs_sem=False):
    from sync import app

    mail = Mail(app)

    if caps_gs_sem:
        recipients = CAPS_GS_SEM_RECIPIENTS
    else:
        recipients = ADMIN_RECIPIENTS
    msg = Message(subject=subject,
                  sender="[email protected]",
                  recipients=recipients)

    if html:
        msg.html = body
    else:
        msg.body = body

    try:
        mail.send(msg)
    except socket.error:
        print "failed to send message %s" % body
        return False

    return True
开发者ID:betheluniversity,项目名称:programs,代码行数:27,代码来源:mail.py

示例3: test_send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def test_send_email():
    mailForm= MailForm()
    if mailForm.validate_on_submit():#表单提交成功的判断
        try:
            app = Flask(__name__)
            app.config['SECRET_KEY'] = 'qiyeboy'
            #下面是SMTP服务器配置
            app.config['MAIL_SERVER'] = 'smtp.163.com' #电子邮件服务器的主机名或IP地址
            app.config['MAIL_PORT'] = '25' #电子邮件服务器的端口
            app.config['MAIL_USE_TLS'] = True #启用传输层安全
            app.config['MAIL_USERNAME'] ='[email protected]' #os.environ.get('MAIL_USERNAME') #邮件账户用户名
            app.config['MAIL_PASSWORD'] = 'hywd1993'#os.environ.get('MAIL_PASSWORD') #邮件账户的密码

            mail = Mail(app)
            receiverName = mailForm.receiver.data #收件人文本框的内容
            styledata = mailForm.style.data#主题文本框的内容
            bodydata  = mailForm.body.data#正文文本框的内容
            msg = Message(styledata,sender='[email protected]',recipients=[receiverName])#发件人,收件人
            msg.body = bodydata
            # send_email('[email protected]','Test email-function',)
            mail.send(msg)
            flash('邮件发送成功!')#提示信息
            return redirect(url_for('.index'))
        except:
            flash('邮件发送失败!')
            return redirect(url_for('.index'))
    return render_template('testemail.html',form=mailForm,name ='[email protected]' )#渲染网页



# @main.route('/secret')
# @login_required
# def secret():
#     return 'Only authenticated users are allowed!'
开发者ID:Y-Rookie,项目名称:flask_blog,代码行数:36,代码来源:views.py

示例4: register

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def register():
    owner = "[email protected]"
    sysadmin = "[email protected]"

    name = request.form.get('name', None)
    email = request.form.get('email', None)
    institute = request.form.get('institute', None)
    message = request.form.get('message', None)
    
    app =Flask(__name__)
    mail=Mail(app)

    _subject = "[Multinet] Request Access Form: %s, %s" % ( name, email )
    
    #1.check if user exists, generate access url for user and save user to db
    _token = generate_id()
    udata = { "email" : email,"name" : name,"institute" : institute,"message" : message, "token": _token }
    
    ret = insert_user(udata)
    
    if not ret:
        return render_template('start.html',errors="This email address is already registered.")

    #2.send new user to admin
    try:
        msg = Message( subject=_subject , recipients=[ owner ], body=message, sender=sysadmin )
        mail.send(msg)
    except Exception,e:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        traceback.print_tb(exc_traceback, limit=5, file=sys.stdout)
开发者ID:emresar,项目名称:multinet.js,代码行数:32,代码来源:views.py

示例5: send_pdf_by_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_pdf_by_email(invoice_id):
    form = InvoiceEmail(request.form)

    if not form.validate():
        return form.errors_as_json()

    invoice = Invoice.find_by_id(invoice_id)
    if not invoice:
        return abort(404)

    message = Message(form.subject.data.encode('utf-8'), sender=(g.member.display, g.member.get_email().encode('utf-8')))
    message.add_recipient(sanitize_address((form.name.data, form.email.data)))
    message.body = form.message.data.encode('utf-8')

    invoice_key = amazons3.get_invoice(invoice)
    message.attach("Invoice_{0}.pdf".format(invoice.reference), "application/pdf", invoice_key.get_contents_as_string())

    mail = Mail()
    mail.init_app(current_app)
    mail.send(message)

    history = InvoiceHistory()
    history.description = 'Sent email to {0}'.format(message.recipients[0])
    history.pdf = invoice_key.key
    history.status = 'SENT'
    history.misc = "{0}\n\n{1}".format(message.subject, message.body)
    history.member_id = g.member.id
    history.invoice_id = invoice.id
    history.save()

    return 'sent', 200
开发者ID:2Leadin,项目名称:api-flask,代码行数:33,代码来源:views.py

示例6: send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_email(msg):
    from routes import app
    with app.app_context():
        mail = Mail()
        mail.init_app(current_app)
        print("hallo world")
        mail.send(msg)
开发者ID:teopeurt,项目名称:flask_redis_queue,代码行数:9,代码来源:sendingmail.py

示例7: UserMail

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def UserMail(user, passwd, smtp, smtp_port, smtp_tsl, smtp_auth, data):
    mail_user = user
    mail_passwd = passwd
    print "--- DEBUG ---"
    print "--- DEBUG ---"
    print data
    print "--- DEBUG ---"
    print "--- DEBUG ---"
    from_addr = user
    to_addr = ';'.join(data.get("from_mail"))
    print to_addr
    mail = Mail(current_app)
    current_app.config.update(
        MAIL_SERVER=smtp,
        MAIL_PORT=smtp_port,
        MAIL_USE_SSL=smtp_auth,
        MAIL_USE_TLS=smtp_tsl,
        MAIL_USERNAME=mail_user,
        MAIL_PASSWORD=mail_passwd
    )
    mail.init_app(current_app)
    msg = Message('Reztoran', sender=from_addr, recipients=to_addr.split(";"))
    msg.html = data.get("text")
    msg.subject = data.get('title')
    mail.send(msg)
    return "ok"
开发者ID:alpankaraca,项目名称:Lecture.Kitchen,代码行数:28,代码来源:FlaskMail.py

示例8: adoptPuppyPage

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def adoptPuppyPage(puppy_id):
    """ Provides a page where adopters can adopt a puppy. """
    puppy = session.query(Puppy).filter_by(id=puppy_id).one()
    if request.method == 'POST':
        try:
            # Change the adopter_puppy field of adopter to reflect the puppy.
            adopter_id = int(request.form['adopterIDField'])
            adopter = session.query(Adopter).filter_by(id=adopter_id).one()
            adopter.adopted_puppy = puppy.id
            session.add(adopter)
            # Change the shelter id of the puppy to None since it has a home.
            puppy.shelter_id = None
            session.add(puppy)
            session.commit()
            # Create a mail instance for use with sending messages.
            mail = Mail(app)
            msg = Message("Hello Em, thanks for adopting %s" % puppy.name,
                    sender="[email protected]",
                    recipients=["[email protected]"])
            mail.send(msg)
            return redirect(url_for('puppyList'))
        except:
            print "The adoption process was unsuccessful."
            return redirect(url_for('puppyList'))
    else:
        return render_template('adopt_puppy.html', puppy=puppy)
开发者ID:BenjaminFraser,项目名称:swiss-tournament,代码行数:28,代码来源:pup_project.py

示例9: sendConfirmation

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def sendConfirmation(app, teamEmail, html = None):
    if not configSet :
        setConfigOptions(app)
    mail = Mail(app)
    msg = Message(subject=_subject, sender=_mailDefaultSender, recipients=[teamEmail], bcc=[_mailDefaultSender])
    msg.body = getEmailTemplate()
    msg.html = html
    mail.send(msg)
开发者ID:astange,项目名称:ExpoProject,代码行数:10,代码来源:mail.py

示例10: send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_email(to,subject,template):
    mail = Mail(application)
    mail.init_app(application)
    msg = Message(
        subject,recipients = [to],
        html = template,
        sender = application.config['MAIL_USERNAME'])
    mail.send(msg)
开发者ID:raju249,项目名称:getresume,代码行数:10,代码来源:helpers.py

示例11: send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_email(subject, text):
    """ Send email """

    msg = Message(subject, sender='[email protected]',
                  recipients=['[email protected]'])
    msg.body = text

    mail = Mail(current_app)
    mail.send(msg)
开发者ID:sudaraka,项目名称:learn-celery,代码行数:11,代码来源:email.py

示例12: send

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send(MessageClass, **kwargs):
    with app.test_request_context():
        mailer = Mail(app)
        mailer.send(MessageClass(**kwargs))

    if 'to' in kwargs:
        return "Mail type: %s, recipient: %s" % (MessageClass.desc(), kwargs['to'])

    return True
开发者ID:bigbag,项目名称:archive_term-flask,代码行数:11,代码来源:mail.py

示例13: send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_email(email, pdf):

    mail_ext = Mail(app)
    subject = "Phone Notes"
    receiver = "[email protected]"
    mail_to_be_sent = Message(subject=subject, recipients=[receiver])
    mail_to_be_sent.body = "This email contains PDF."
    mail_to_be_sent.attach("file.pdf", "application/pdf", pdf)
    mail_ext.send(mail_to_be_sent)
开发者ID:breno601,项目名称:phone_note,代码行数:11,代码来源:email.py

示例14: count_words_at_url

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def count_words_at_url(url, mailAddress):
    resp = requests.get(url)
    result = len(resp.text.split())
    mail = Mail(current_app)
    msg = Message("test", recipients=["[email protected]"])
    msg.body = str(result)
    msg.add_recipient(str(mailAddress))
    mail.send(msg)
    return result
开发者ID:ipdae,项目名称:flaskr,代码行数:11,代码来源:utils.py

示例15: send_async_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import send [as 别名]
def send_async_email(app, msg, list_id, manager_id, uu):
    with app.app_context():
        try:
            OA_Email_Url(list_id, manager_id, uu, 0).add()
            db.session.commit()
            mail = Mail(app)
            mail.send(msg)
        except:
            # 回滚
            db.session.rollback()
            logger.exception("exception")
开发者ID:wangscript,项目名称:oa-1,代码行数:13,代码来源:fysp.py


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