Example #1
0
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'] ='13259744109@163.com' #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='13259744109@163.com',recipients=[receiverName])#发件人,收件人
            msg.body = bodydata
            # send_email('2531145412@qq.com','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 ='13259744109@163.com' )#渲染网页



# @main.route('/secret')
# @login_required
# def secret():
#     return 'Only authenticated users are allowed!'
Example #2
0
	def create_app():

		global db, bootstrap, mail, login_manager, moment, pagedown
		app = Flask(__name__)

		from main import main as main_blueprint
		from auth import auth as auth_blueprint
		from admin import admin as admin_blueprint

		app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://flask:gf37888676@172.17.0.25/flask'
		app.config['SQLAlCHEMY_COMMIT_ON_TEARDOWN'] = True
		app.config['FLASK_ADMIN'] = 'iamawar3player@163.com'
		app.config['FLASK_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
		app.config['FLASK_MAIL_SENDER'] = 'Flasky Admin <iamawar3player@163.com>'
		app.config['MAIL_SERVER'] = 'smtp.163.com'
		app.config['MAIL_PORT'] = 25
		app.config['MAIL_USE_TLS'] = False
		app.config['MAIL_USERNAME'] = 'iamawar3player@163.com'
		app.config['MAIL_PASSWORD'] = 'fan86797121'
		app.config['DEBUG'] = True
		app.config['FLASKY_POSTS_PER_PAGE'] = 10
		app.config['SECRET_KEY'] = 'gf37888676'
		app.register_blueprint(main_blueprint)
		app.register_blueprint(auth_blueprint, url_prefix='/auth')
		app.register_blueprint(admin_blueprint, url_prefix='/admin')

		db = db.init_app(app)
		mail = mail.init_app(app)
		bootstrap = bootstrap.init_app(app)
		login_manager = login_manager.init_app(app)
		moment = moment.init_app(app)
		pagedown = pagedown.init_app(app)

		return app
Example #3
0
def create_app():
    app = Flask(__name__)
    app.config.update(
        CELERY_BROKER_URL='redis://localhost:6379/0',
        CELERY_RESULT_BACKEND='redis://localhost:6379/0'
    )
    app.config['MAIL_SERVER'] = 'smtp.gmail.com'
    app.config['MAIL_PORT'] = 587
    app.config['MAIL_USE_TLS'] = True
    app.config['MAIL_USERNAME'] = admin_imap
    app.config['MAIL_PASSWORD'] = admin_pass
    app.config['MAIL_DEFAULT_SENDER'] = 'server-error@example.com'

    return app
Example #4
0
from wtforms.validators import Required
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.mail import Mail, Message

basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
app.config['SQLALCHEMY_DATABASE_URI'] =\
    'sqlite:///' + os.path.join(basedir, 'data.sqlite')
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD')
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <flasky@example.com>'
app.config['FLASKY_ADMIN'] = os.environ.get('FLASKY_ADMIN')

manager = Manager(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
mail = Mail(app)


class Role(db.Model):
    __tablename__ = 'roles'
app.json_encoder = JSONEncoder

app.config['BABEL_DEFAULT_LOCALE'] = 'ru'
babel = Babel(app)


@babel.localeselector
def get_locale():
    return 'ru'

app.config['MAIL_SERVER'] = dotenv.get(
    'KNOTMARKER_MAIL_SERVER', 'smtp.gmail.com')
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = dotenv.get(
    'KNOTMARKER_MAIL_USERNAME', 'knotmarker@gmail.com')
app.config['MAIL_PASSWORD'] = dotenv.get('KNOTMARKER_MAIL_PASSWORD')

mail = Mail(app)

app.config['MONGODB_DB'] = dotenv.get('KNOTMARKER_MONGODB_DB', 'knotmarker')
app.config['MONGODB_HOST'] = dotenv.get('KNOTMARKER_MONGODB_HOST', 'localhost')
app.config['MONGODB_PORT'] = dotenv.get('KNOTMARKER_MONGODB_PORT', 27017)
app.config["SECRET_KEY"] = bytes(dotenv.get('KNOTMARKER_SECRET_KEY'), 'utf8')
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_CONFIRMABLE"] = True
app.config["SECURITY_RECOVERABLE"] = True
app.config["SECURITY_CHANGEABLE"] = True
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
app.config['SECURITY_PASSWORD_SALT'] = bytes(dotenv.get('KNOTMARKER_PASSWORD_SALT'), 'utf8')
Example #6
0
    'secret_key': os.environ['SECRET_KEY'],
    'publishable_key': os.environ['PUBLISHABLE_KEY']
}

stripe.api_key = stripe_keys['secret_key']

app = Flask(__name__)
heroku = Heroku(app)

#need to explicity define the mail gun smtp port since flask_heroku
#leaves this out

app.config["MAIL_SERVER"] = os.environ["MAILGUN_SMTP_SERVER"]
app.config['MAIL_PORT'] = os.environ["MAILGUN_SMTP_PORT"]
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = os.environ["MAILGUN_SMTP_LOGIN"]
app.config['MAIL_PASSWORD'] = os.environ["MAILGUN_SMTP_PASSWORD"]

mail = Mail(app)

app.config["MONGODB_USERNAME"] = app.config['MONGODB_USER'] #flask_heroku naming convention mismatch, with MongoEngine this time
db = MongoEngine(app)

if not 'Production' in os.environ:
    app.debug = True
    from flask_cake import Cake
    cake = Cake(app, ["build"]) #this converts our coffeescript to javascript
    from flask.ext.less import LESS
    less = LESS(app)
else:
    app.debug = False
Example #7
0
SERVICES = [SERVICE_POD, SERVICE_TLP]

# models
MODELS_POD_OCR = "ocr"
MODELS_POD_BAYES_SPAM = "bayes_spam"
MODELS_POD_FACE_DETECT = "face_detect"
MODELS = [MODELS_POD_OCR, MODELS_POD_BAYES_SPAM, MODELS_POD_FACE_DETECT]


# mail settings
PRAXYK_API_APP.config['MAIL_SERVER']   = 'smtp.googlemail.com'
PRAXYK_API_APP.config['MAIL_PORT']     = 587
PRAXYK_API_APP.config['MAIL_USE_TLS']  = True
PRAXYK_API_APP.config['MAIL_USE_SSL']  = False
# gmail authentication
PRAXYK_API_APP.config['MAIL_USERNAME'] = apiconf['email']
PRAXYK_API_APP.config['MAIL_PASSWORD'] = apiconf['emailpassword']

mail = Mail(PRAXYK_API_APP)

# mail accounts
PRAXYK_API_APP.config['MAIL_DEFAULT_SENDER'] = 'from@example.com'

# default access token expiration time (24 hours)
TOKEN_EXPIRATION = apiconf['token_expiration']


from models.sql.user import User, Role, Transaction, Token, Payment_Info

user_datastore = SQLAlchemyUserDatastore(db, User, Role)
security = Security(PRAXYK_API_APP, user_datastore)
"""
celery command:
celery --app=flask_demo.celery worker --loglevel=info
"""

app = Flask(__name__)
app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/0'
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost:6379/0'

celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)

app.config['MAIL_SERVER'] = 'smtp.qq.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = '296701047@qq.com'  # os.environ.get('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = 'password'  # os.environ.get('MAIL_PASSWORD')
app.config['MAIL_DEFAULT_SENDER'] = '296701047@qq.com'

mail = Mail(app)


@celery.task
def send_async_email(msg):
    """Background task to send an email with Flask-Mail."""
    with app.app_context():
        mail.send(msg)
    return 'success'


@app.route('/', methods=['GET', 'POST'])
Example #9
0
moment = Moment()

if __name__ == '__main__':
    bootstrap = Bootstrap()


    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'hard to guess string'
    app.config['SQLALCHEMY_DATABASE_URI'] =\
        'mysql://root:mopon@172.16.34.7:3306/test'
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

    app.config['MAIL_SERVER'] = 'smtp.qiye.163.com'
    app.config['MAIL_PORT'] = 25
    app.config['MAIL_USE_TLS'] = False
    app.config['MAIL_USERNAME'] = 'chenxiaolu.sz@mopon.cn'
    app.config['MAIL_PASSWORD'] = 'cxl@taijiu2015'
    app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
    app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <chenxiaolu.sz@mopon.cn>'
    app.config['FLASKY_ADMIN'] = 'chenxiaolu.sz@mopon.cn'
    app.config['FLASKY_POSTS_PER_PAGE'] = 2
    app.config['FLASKY_FOLLOWERS_PER_PAGE'] = 2
    app.config['FLASKY_COMMENTS_PER_PAGE'] = 2

    bootstrap.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    pagedown.init_app(app)
Example #10
0
#configuration
DATABASE = '/tmp/flasktest.db'
DEBUG = True
SECRET_KEY = 'development key'
USERNAME = 'admin'
PASSWORD = 'default'

app = Flask(__name__)
app.config.from_object(__name__)
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'themilkmanshipping@gmail.com'
app.config['MAIL_PASSWORD'] = 'brian333'
app.config['DEFAULT_MAIL_SENDER'] = 'themilkmanshippinggmail.com'


def max_function(a,b):
  return max(a,b)

app.jinja_env.globals.update(max_function=max_function)

mail = Mail(app)


import Roo.views

@app.teardown_request
    username = StringField('Username')
    eMail = StringField('eMail')			# users need to select at least one of these!
    phone = StringField('Phone #') 
    
    ##	END Form definitions, START APP DEFS	##
    
app = Flask(__name__)
app.debug = True
app.config['PROPAGATE_EXCEPTIONS'] = True
app.config['SECRET_KEY'] = 'JWT_code_isMadeOfThis'
	
	## and for sending retrieval eMails	##
	
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'marioat@juno.com'
app.config['MAIL_PASSWORD'] = '*****'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True

auth = HTTPTokenAuth(scheme='Token')

mail = Mail(app)

	##	List of users should be built off Select * from users SQL command, but for now...	##
	
users = [
    User('Larry Gold', 'Death2Hackerz!', 'larrygold@notgmail.com', '8601234567'),
    User('Den Wu', 'N0bodywillguessthispwd!', 'denofwu@nothotmail.com', '2121234456'),
    User('Fred Smith', 'Interview!', 'fredsmith@notgmail.com', '2031234567'),
]
Example #12
0
# This program is used for testing flask-mail extension .
# something wrong in my app, so I must learn how to use this extension .
# password nwntuhwdkrrbbbbe

from flask import Flask
from flask_mail import Mail, Message
from flask_script import Manager
app = Flask(__name__)

app.config['MAIL_SERVER'] = 'smtp.qq.com'
app.config['MAIL_PORT'] = '25'
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_USERNAME'] = '80551xx'
app.config['MAIL_PASSWORD'] = 'nwntuhwdkrrbbbbe'
app.config['FLASKY_MAIL_SENDER'] = "80551xx@qq.com"

mail = Mail(app)
manager = Manager(app)


@app.route('/')
def index():
    msg = Message('subject', sender=app.config['FLASKY_MAIL_SENDER'], recipients=['228787xx@qq.com'])
    msg.body = 'body'
    msg.html = '<b>HTML</b> body'
    mail.send(msg)

    return '<h1>Sent successfully</h1>'

if __name__ == "__main__":
Example #13
0
# encoding:utf-8
from flask import Flask,render_template,session,redirect,url_for,flash,request
from flask.ext.bootstrap import Bootstrap
from flask.ext.moment import Moment
from datetime import datetime
from flask.ext.wtf import Form
from wtforms import SubmitField,StringField
from wtforms.validators import required
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.mail import Mail
from flask.ext.mail import Message
from threading import Thread
import RealIP
import dbconfig

import sys
reload(sys)
sys.setdefaultencoding('utf-8')
#初始化Flask 实例,添加秘钥,数据库参数配置,邮箱配置
app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
app.config['SQLALCHEMY_DATABASE_URI'] = dbconfig.SQLALCHEMY_DATABASE_URI
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = dbconfig.SQLALCHEMY_COMMIT_ON_TEARDOWN
app.config['MAIL_SERVER'] = 'smtp.139.com'
app.config['MAIL_PORT'] = 25
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = '18898761417@139.com'
app.config['MAIL_PASSWORD'] = '***************'
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <18898761417@139.com>'
Example #14
0
from flask import Flask, session, jsonify, request
from flask.ext.cors import CORS
from flask_mail import Mail, Message
from database import NewOrder, OrderUpdation, FetchOrders
import gc
import json

app = Flask(__name__)
app.config['SECRET_KEY'] = 'A0Zr98j/3yX R~Xsa!jmN]LWX/,?RT'
app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'themidnightsaviour'
app.config['MAIL_PASSWORD'] = 'tmsadmin123'

mail = Mail(app)
CORS(app)

def allowed_file(filename):
  return filename.rsplit('.', 1)[-1].lower() in app.config['ALLOWED_EXTENSIONS']

@app.route('/', methods=['GET', 'POST'])
def home():
  print sendmail('sahilsehgal1995@gmail.com', 'Trying hard', 'Trying')
  return 'TMS'
    #return app.send_static_file("index.html")

def sendmail(email, message, subject):
  try:
    msg = Message(subject,sender="No-Reply@lenme.in",recipients=[email])
    msg.body = "Lenme"
Example #15
0
File: app.py Project: angcbi/flaskr
from flask_migrate import Migrate, MigrateCommand
from flask_mail import Mail, Message
from flask_redis import FlaskRedis


app = Flask(__name__)
app.config['SECRET_KEY'] = 'skdfjodglksdgjower'
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://test3:test3@localhost:3306/test3'
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

app.config['MAIL_SERVER'] = 'smtp.qq.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USERNAME'] = 'faladihuan@qq.com'
app.config['MAIL_PASSWORD'] = 'vxclhkigrzfjibgf'

app.config['MAIL_SUBJECT_PREFIX'] = '[Admin]'
app.config['MAIL_SENDER'] = 'Admin <faladihuan@qq.com>'
app.config['ADMIN'] = '836268808@qq.com'

app.config['REDIS_URL'] = 'redis://:123456@localhost:6379/0'

manager = Manager(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
mail = Mail(app)
Example #16
0
#!/home/flask_learn/flask/bin/python
# encoding: utf-8
from flask import Flask
from flask_mail import Mail, Message

app = Flask(__name__)
app.config['MAIL_SERVER'] = 'smtp.qq.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = '337859457@qq.com'
app.config['MAIL_PASSWORD'] = 'quergtfjoyzybjgi'

mail = Mail(app)
msg = Message(u'邮件主题', sender='337859457@qq.com', recipients=['lijingjing.chn@gmail.com'])
msg.body = u'邮件内容'
msg.html = u"<h1>邮件的html模板<h1> body"

with app.app_context():
    mail.send(msg)

Example #17
0
from flask import Flask
from flask.ext.mail import Mail, Message


app = Flask(__name__)
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_USERNAME'] = 'test.account'
app.config['MAIL_PASSWORD'] = open('/home/sforman/GazAd').read().strip()

# MAIL_DEBUG = default app.debug
# MAIL_SUPPRESS_SEND 

mail = Mail(app)

msg = Message(
  'Yo, testing email, DONOTREPLY Yo',
  body='''
"The history of mankind for the last four centuries is rather like that of
an imprisoned sleeper, stirring clumsily and uneasily while the prison that
restrains and shelters him catches fire, not waking but incorporating the
crackling and warmth of the fire with ancient and incongruous dreams, than
like that of a man consciously awake to danger and opportunity."
--H. P. Wells, "A Short History of the World"
''',
  sender="test.account@gazzaleylab.ucsf.edu",
  recipients=[
    'forman.simon@gmail.com',
    'morgan.hough@gmail.com',
    ],
  )
Example #18
0
import os
import yaml
import operator
import settings

mail = Mail()

app = Flask(__name__)
app.config.from_pyfile('settings.py')
app.secret_key = 'B0wieD0g6'

#Email server information
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'sakqm2@mst.edu'
app.config['MAIL_PASSWORD'] = 'Acdv4567'
mail.init_app(app)

class Blog(object):
    def __init__(self, path, root_dir='', file_ext=None):
        self.root_dir = root_dir
        self.file_ext = file_ext if file_ext is not None else app.config['POSTS_FILE_EXTENSION']
        self._app = app
        self._cache = {}
        self._init_cache()

    @property
    def posts(self):
        newest_first = sorted(self._cache.values(), key = operator.attrgetter('date'), reverse = True)
        print newest_first
Example #19
0
@login_manager.user_loader
def load_user(user_id):
	return adapter.get_user_by_id(user_id)

@app.errorhandler(400)
def page_not_found(e):
    return render_template('login.html'),400

app.config.from_object('config')
 
app.config['SECURITY_POST_LOGIN'] = '/profile'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'arqsoft12015@gmail.com'
app.config['MAIL_PASSWORD'] = 'arquitectura2015'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True

api.add_resource(HomeController, '/',endpoint="home")
api.add_resource(RegisterController, '/register',endpoint="register")
api.add_resource(LoginController, '/login',endpoint="login")
api.add_resource(LogoutController, '/logout',endpoint="logout")
api.add_resource(PerfilController, '/perfil',endpoint="perfil")
api.add_resource(EditarUsuarioController, '/editarme', endpoint="editar_perfil")
api.add_resource(EventoController, '/evento/<evento_id>',endpoint="evento")
api.add_resource(EditarEventoController, '/editar/<evento_id>',endpoint="editar_evento")
api.add_resource(NuevoEventoController, '/nuevo_evento',endpoint="nuevo_evento")
api.add_resource(CrearRecursoController, '/crear_recurso',endpoint="crear_recurso")
api.add_resource(AsignarRecursoController, '/asignar_recurso', endpoint="asignar_recurso")
Example #20
0
from flask_mail import Mail
from flask_mail import Message

import threading

import forms
import model

app = Flask(__name__)

##https://support.google.com/accounts/answer/6010255?hl=en
app.config['MAIL_SERVER'] = "smtp.gmail.com"
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = "eduardo@codigofacilito.com"
app.config['MAIL_PASSWORD'] = "C=eQ9KF="


mail = Mail(app)

def send_email(user):
	msg = Message("Test numero uno",
							sender="eduardo@codigofacilito.com",
							recipients=["eduardo78d@gmail.com"])
	msg.html = render_template('thanks.html', user = user)
	mail.send(msg)

@app.before_request
def before_request():
	g.db = model.DATABASE
Example #21
0
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.mail import Mail, Message
from threading import Thread

basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
app.config['SQLALCHEMY_DATABASE_URI'] =\
    'sqlite:///' + os.path.join(basedir, 'data.sqlite')
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = "cakephp.php@gmail.com"
#app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD')
app.config['MAIL_PASSWORD'] = "zfvluxtohgbhloew"
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <mohmed_e@hotmail.com>'
#app.config['FLASKY_ADMIN'] = os.environ.get('FLASKY_ADMIN')
app.config['FLASKY_ADMIN'] ="mohmed_e@hotmail.com"

manager = Manager(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
mail = Mail(app)

Example #22
0
from flask_mail import Mail
from flask_mail import Message
import config

app = Flask(__name__)
# app.config.from_object('config')
app.config['CAS_SERVER'] = 'https://netid.rice.edu'
app.config['CAS_AFTER_LOGIN'] = 'afterlogin'
app.config['APP_URL'] = 'localhost:5000'
app.config.setdefault('CAS_USERNAME_SESSION_KEY', 'CAS_USERNAME')
CAS(app)

# Email setup
app.config['MAIL_SERVER'] = 'smtp.zoho.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = config.MAIL_USERNAME
app.config['MAIL_PASSWORD'] = config.MAIL_PASSWORD
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_SUPPRESS_SEND'] = False
app.config['TESTING'] = False
mail = Mail(app)


def make_dicts(cursor, row):
    return dict((cursor.description[idx][0], value) for idx, value in enumerate(row))


con = lite.connect("wellbeing.db", check_same_thread=False)
con.row_factory = make_dicts
cur = con.cursor()
Example #23
0
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.security import Security, SQLAlchemyUserDatastore, \
    UserMixin, RoleMixin, login_required
from flask_mail import Mail

# Create app
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'super-secret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'

# Flask Mail'
app.config['MAIL_SERVER'] = 'smtp.example.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'username'
app.config['MAIL_PASSWORD'] = 'password'
mail = Mail(app)

# Create database connection object
db = SQLAlchemy(app)

# Define models
roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
        db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))

class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))
Example #24
0
import os
from flask import Flask
from flask.ext.mail import Mail, Message


app = Flask(__name__)

app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'mssk.me@gmail.com'
app.config['MAIL_PASSWORD'] = 'arazalan'
app.config['DEFAULT_MAIL_SUBJECT'] = '[Politburo Voting Results]'
app.config['DEFAULT_MAIL_SENDER'] = 'Admin <admin@example.com>'
app.config['SECRET_KEY'] = 'random_string'
app.config['DEFAULT_ADMIN'] = 'Admin <hypnopompicindex@gmail.com>'

mail = Mail(app)




def send_email(to, subject, template, **kwargs):
    msg = Message(app.config['DEFAULT_MAIL_SUBJECT'] + ' ' + subject,
        sender=app.config['DEFAULT_MAIL_SENDER'], recipients=[to])
    msg.attach(filename='abc.png', content_type="image/png")
    mail.send(msg)

Example #25
0

config = configparser.ConfigParser()
config.readfp(codecs.open("../config/config.ini", "r", "utf-8"))

app = Flask(__name__)

app.config['HEADERS'] = {'Referer': 'http://music.163.com'}
app.config['OFFSET'] = 0
app.config['LIMIT'] = 100
app.config['JSON_AS_ASCII'] = False

app.config['MAIL_SERVER'] = config['MAIL']['SERVER']
app.config['MAIL_PORT'] = int(config['MAIL']['PORT'])
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = config['MAIL']['USERNAME']
app.config['MAIL_PASSWORD'] = config['MAIL']['PASSWORD']

mail = Mail(app)


"""
API website template related
"""

@app.route('/', methods=['GET'])
def host():
	return redirect('/v1')


@app.route('/v1', methods=['GET'])
from flask import Flask
from flask_mail import Mail, Message

app =Flask(__name__)
mail=Mail(app)

app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'ishan.nitj@gmail.com'
app.config['MAIL_PASSWORD'] = 'willingtodie'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
mail = Mail(app)

@app.route("/")
def index():
   msg = Message('Hello', sender = 'ishan.nitj@gmail.com', recipients = ['ishan.nitj@gmail.com'])
   msg.body = "Hello Flask message sent from Flask-Mail"
   with app.open_resource("Notes.txt") as fp:
      msg.attach("Notes.txt","txt", fp.read())
   mail.send(msg)
   return "Sent"

if __name__ == '__main__':
   app.run(debug = True)

Example #27
0
import os 
from flask import Flask, render_template, request, redirect, url_for
from flask_mail import Mail, Message as MailMessage
import json 
import requests 

app = Flask(__name__)
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = ''
app.config['MAIL_PASSWORD'] = ''
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
mail = Mail(app)

@app.route('/')
def get_malimo_home():

	workFilePath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static/media/work_experience.json') 
	with open(workFilePath, 'r') as work_file:
		content = work_file.read()
		workData = json.loads(content)
		work_file.close()

	return render_template('index.html', work_data=workData) 



@app.route('/sendMessage', methods=['POST']) 
def messenger():
	inquirerName = request.form['name']
Example #28
0
from wtforms.validators import InputRequired,Length,Email
from passlib.hash import sha256_crypt
# from db import *
from flask import Flask
from flask_mail import Mail, Message#pip install flask_mail
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
from flask import Flask
import os
from functools import wraps
app=Flask(__name__)
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
# app.config['SECRET_KEY']='Thisissupposedtobesecret!'
gmail=Mail(app)
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'shivam.vku@gmail.com'
app.config['MAIL_PASSWORD'] = '7569880950vineet'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
gmail = Mail(app)

app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = 'flaskappemp'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
mysql=MySQL(app)#https://realpython.com/blog/python/the-minimum-viable-test-suite/

@app.route('/')
def home():
	return render_template('home.html')
Example #29
0
app = Flask(__name__, static_url_path='')
app.debug = True
#app.debug = False
app.config['SECRET_KEY'] = 'secret!'
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///wv.db'

app.config['SECURITY_TRACKABLE'] = True
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_EMAIL_SENDER'] = 'no-reply@pollywss.paldeploy.com'

app.config['MAIL_SERVER'] = '192.168.20.18'
app.config['MAIL_PORT'] = 25
#app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_USERNAME'] = 'flycam'
app.config['MAIL_PASSWORD'] = 'flyspec'
mail = Mail(app)

socketio = SocketIO(app)

# Create database connection object
db = SQLAlchemy(app)

# Define models
roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
        db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))

class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
Example #30
0
from werkzeug.security import generate_password_hash, check_password_hash
from flask.ext.mail import Mail, Message
from ftplib import FTP
from flask.ext.login import LoginManager, login_required

basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)

"""
Note: setting these variables through the local environment & using os.environ to access them is preferred for security reasons
"""
app.config['MAIL_SERVER'] = ""
app.config['MAIL_PORT'] = ""
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'test@test.com'
app.config['MAIL_PASSWORD'] = 'testpw' 

app.config['SQLALCHEMY_DATABASE_URI'] =\
	'sqlite:///' + os.path.join (basedir, 'data.sqlite')
#app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
#uncomment this line if you want to use Heroku, comment instead the one before it
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

app.config['UPLOAD_FOLDER'] = './static/balls'

app.permanent_session_lifetime = timedelta(seconds=60)
app.config['SECRET_KEY'] = 'veryhard2guess'
#be more original

FTP_USER = '222'