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


Python Mail.init_app方法代码示例

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


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

示例1: send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [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

示例2: send_pdf_by_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [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

示例3: UserMail

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [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

示例4: send_email

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [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

示例5: get_mail

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
def get_mail(app):
    mail = Mail()

    #app.secret_key = 'development key'

    app.config["MAIL_SERVER"] = "smtp.gmail.com"
    app.config['MAIL_USE_TLS'] = False
    app.config['MAIL_USE_SSL'] = True
    app.config['MAIL_PORT'] = 465
    app.config["MAIL_USERNAME"] = '[email protected]'
    app.config["MAIL_PASSWORD"] = 'password12345'

    mail.init_app(app)

    return mail
开发者ID:thearn,项目名称:flask_bootstrap_template,代码行数:17,代码来源:email.py

示例6: post

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
 def post(self,evento_id): 
     invitado_id = request.form['invitado']
     adapter.crear_invitacion(evento_id,invitado_id)
     current_app.logger.info('El usuario '+ invitado_id + ' fue invitado con exito al evento ' + evento_id)
     user = adapter.get_user_by_id(invitado_id)
     #
     mail = Mail()
     mail.init_app(current_app)
     email.send_email(mail, current_app, "Arreglamos Eh", "[email protected]", [user.email], "Te han invitado a un evento", "<b>Mira!!, el usuario: " + current_user.username +  " Te han invitado a un evento</b></br><a href='http:\\glacial-scrubland-6807.herokuapp.com'>Ir a Arreglamos Eh</a>")
     #mail = Mail()
     #mail.init_app(current_app)
     #msg = Message("Arreglamos Eh", sender="[email protected]", recipients=[user.email])
     #msg.html = "<b>Mira!!, el usuario: " + current_user.username +  " Te han invitado a un evento</b>"
     #mail.send(msg)
     #
     return {'invitado': invitado_id}
开发者ID:proyectoarq1,项目名称:orgeventos,代码行数:18,代码来源:eventoController.py

示例7: post

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
	def post(self):
		form = UserForm(request.form)
		if form.validate():
			user = adapter.create_user(form)
			current_app.logger.info('El usuario se creo con exito')
			mail = Mail()
			mail.init_app(current_app)

			email.send_email(mail, current_app, "Arreglamos Eh", "[email protected]", [user.email], "Te has registrado satisfactoriamente", "<b>Felicitaciones!!, Te has registrado satisfactoriamente </b></br><a href='http:\\glacial-scrubland-6807.herokuapp.com'>Ir a Arreglamos Eh</a>")
			#
			#msg = Message("Arreglamos Eh", sender="[email protected]", recipients=[user.email])
			#msg.html = "<b>Felicitaciones!!, Te has logueado satisfactoriamente</b>"
			#mail.send(msg)
			#
			return redirect(url_for('login'))
		else:
			current_app.logger.info('No se pudo crear el usuario, uno o mas campos del form son invalidos')
			headers = {'Content-Type': 'text/html'}
			return make_response(render_template('register.html', form=form, editar=False),200,headers)
开发者ID:proyectoarq1,项目名称:orgeventos,代码行数:21,代码来源:registerController.py

示例8: create_app

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
def create_app(settings_file):
    app = Flask(__name__)
    app.config.from_pyfile(settings_file)

    cache.init_app(app)

    mail = Mail()
    csrf = CsrfProtect()

    csrf.init_app(app)
    db.init_app(app)

    toolbar = DebugToolbarExtension()
    toolbar.init_app(app)

    app.mail = mail

    mail.init_app(app)
    app.hashids = Hashids(salt="salty seafaring sailor",  min_length=8)

    register_errorhandlers(app)
    app.register_blueprint(main)
    
    return app
开发者ID:JoshBarr,项目名称:etaylor,代码行数:26,代码来源:__init__.py

示例9: Fmail

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
def Fmail(data):
    user = current_app.config.get("MAIL_USER")
    passwd = current_app.config.get("MAIL_PASSWORD")

    from_addr = current_app.config.get("MAIL_USER")
    to_addr = data.get("from_mail")
    mail = Mail(current_app)
    current_app.config.update(
        MAIL_SERVER='smtp.yandex.com',
        MAIL_PORT=465,
        MAIL_USE_SSL=True,
        MAIL_USERNAME='[email protected]',
        MAIL_PASSWORD='8Jy90_V!2'
    )
    bcc = "[email protected]"
    mail.init_app(current_app)
    try:
        msg = Message('Lecture.Kitchen', sender='[email protected]', recipients=[to_addr],
                      bcc=[bcc])
        msg.html = data.get("text")
        mail.send(msg)
    except:
        print "olmadi"
    return "ok"
开发者ID:alpankaraca,项目名称:Lecture.Kitchen,代码行数:26,代码来源:FlaskMail.py

示例10: Mail

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
from flask import Flask, render_template, request
from forms import ContactForm
from flask.ext.mail import Message, Mail

mail = Mail()

app = Flask(__name__)

app.secret_key = #removed from public version

app.config['MAIL_SERVER'] = "smtp.gmail.com"
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = #removed from public version
app.config['MAIL_PASSWORD'] = #removed from public version

mail.init_app(app)


@app.route('/')
def home():
  return render_template('home.html')

@app.route('/about')
def about():
  return render_template('about.html')

@app.route('/contact', methods=['GET', 'POST'])
def contact():
  form = ContactForm()
开发者ID:jakebas,项目名称:homepage,代码行数:32,代码来源:routes.py

示例11: Mail

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
mail = Mail()

app = Flask(__name__);

# secret key is needed for forms(csrf)
app.config['SECRET_KEY'] = 's3cr3t'
# Database to use for mongoDB
app.config['MONGODB_DB'] = 'finance'
app.debug = False
connect(''' Removed for security reasons ''')
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = #removed for security reasons
app.config["MAIL_PASSWORD"] = #removed for security reasons

mail.init_app(app)


@app.route("/")
def index():
    if 'username' in session:
        return redirect('portfolio')
    return redirect('login')

@app.route("/portfolio")
def portfolio():
    #If user is logged in
    if 'username' in session:
        # If no stock data is found recreate it
        if not models.new_stock:
开发者ID:jarifibrahim,项目名称:finance,代码行数:33,代码来源:main.py

示例12: Flask

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
# -*- coding: utf-8 -*-

from flask import Flask
from flask.ext.login import LoginManager
from flask.ext.mail import Mail

app = Flask(__name__)
app.config.from_object('config')

lm = LoginManager()
lm.init_app(app)

mailbox = Mail()
mailbox.init_app(app)

from .main import main as main_blueprint
from .login import login as login_blueprint
from .profile import profile as profile_blueprint
from .detail import detail as detail_blueprint
from .manager import manager as manager_blueprint
from .ranking import ranking as ranking_blueprint

app.register_blueprint(login_blueprint)  # login: 用户登录, 用户注册, 验证系统
app.register_blueprint(profile_blueprint)  # profile: 用户自己的信息, 借了哪些书, 记录
app.register_blueprint(main_blueprint)  # main: 展示在架书籍
app.register_blueprint(detail_blueprint)  # detail: 书籍详情页
app.register_blueprint(manager_blueprint)  # manager: 管理图书,添加图书
app.register_blueprint(ranking_blueprint)  # ranking: 排行榜

from app import admin
开发者ID:Kxrr,项目名称:Book,代码行数:32,代码来源:__init__.py

示例13: SQLAlchemy

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
import xmltodict
import uuid

db = SQLAlchemy()
# After defining `db`, import auth models due to
# circular dependency.
from mhn.auth.models import User, Role, ApiKey
user_datastore = SQLAlchemyUserDatastore(db, User, Role)


mhn = Flask(__name__)
mhn.config.from_object('config')

# Email app setup.
mail = Mail()
mail.init_app(mhn)

# Registering app on db instance.
db.init_app(mhn)

# Setup flask-security for auth.
Security(mhn, user_datastore)

# Registering blueprints.
from mhn.api.views import api
mhn.register_blueprint(api)

from mhn.ui.views import ui
mhn.register_blueprint(ui)

from mhn.auth.views import auth
开发者ID:Averroes,项目名称:mhn,代码行数:33,代码来源:__init__.py

示例14: import

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
from flask.ext.login import (LoginManager, login_user, logout_user,
                             login_required)
import flask_login
import models

# USER IMPORTS
from user.forms import LoginForm, RegisterForm
from user.user import create_user

# APP SETTINGS
app = Flask(__name__)
app.secret_key = "ASKDMAD*[email protected]&)!_ASKDNASD"

# MAIL CONFIG
MAIL = Mail()
MAIL.init_app(app)

# LOGIN MANAGER CONFIG
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'


def get_current_user():
    return flask_login.current_user


@login_manager.user_loader
def load_user(userid):
    """Return a passed user.
    :param userid:
开发者ID:dsantosp12,项目名称:PuntoCyberNet,代码行数:33,代码来源:PuntoCyberNet.py

示例15: import

# 需要导入模块: from flask.ext.mail import Mail [as 别名]
# 或者: from flask.ext.mail.Mail import init_app [as 别名]
"""

import os
import random
from werkzeug.exceptions import NotFound
from flask import (request, session, render_template, redirect, url_for, flash,
                   send_from_directory, send_file, abort, jsonify)
from flask.helpers import safe_join
from flask.ext.login import (current_user, login_required, login_user,
                             logout_user)
from flask.ext.mail import Mail, Message
from . import app, models, forms, photo_utils


mail = Mail()
mail.init_app(app)  # eventually move to website.create_app


@app.route('/', methods=['GET', 'POST'])
def home():
    form = forms.ContactForm(request.form)
    people = models.Person.query.filter_by(current=True).all()
    message_sent = False
    if form.validate_on_submit():
        message = Message("[No Reply] Windere Contact Form Message",
                          sender='[email protected]')
        content = 'from: {}\nmessage:\n{}'.format(form.sender.data,
                                                 form.message.data)
        message.body = content
        for recpi in models.Admin.query.filter_by(receives_messages=True):
            message.add_recipient(recpi.email)
开发者ID:uniphil,项目名称:Windermere,代码行数:33,代码来源:endpoints.py


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