Commit 1d40f9d8 authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

integrating mailing

parent efd170e7
from app import app from app import app
from flask_mail import Mail, Message
from flask import render_template, request, redirect, url_for, session, send_from_directory, flash from flask import render_template, request, redirect, url_for, session, send_from_directory, flash
from flask_mail import Message
import psycopg2 import psycopg2
import app.dao.user.user as ud import app.dao.user.user as ud
...@@ -23,6 +25,7 @@ MAX_PG_ENTRIES_USERS = 10 ...@@ -23,6 +25,7 @@ MAX_PG_ENTRIES_USERS = 10
MAX_PG_ENTRIES_DATA = 10 MAX_PG_ENTRIES_DATA = 10
MAX_PG_ENTRIES_GRAPH_HOURS = 24 MAX_PG_ENTRIES_GRAPH_HOURS = 24
mail = Mail(app)
@app.route('/') @app.route('/')
def index(): def index():
...@@ -583,5 +586,22 @@ def alarm_rm(): ...@@ -583,5 +586,22 @@ def alarm_rm():
else: else:
return redirect(url_for('index')) return redirect(url_for('index'))
@app.route('/mail')
def send_mail():
print (1)
msg = Message('test message',
sender = 'hpcaiotserver@gmail.com',
recipients = ['al373630@uji.es'])
print (2)
msg.body = 'Hello vlad, alert is here!'
print (3)
res = mail.send(msg)
print (res)
return res
def pend_delete_all_ack(): def pend_delete_all_ack():
pend.delete_all_ack() pend.delete_all_ack()
...@@ -24,6 +24,13 @@ class Config(object): ...@@ -24,6 +24,13 @@ class Config(object):
# manual user signup by default # manual user signup by default
USERS_SIGNUP = False USERS_SIGNUP = False
# mail server config
MAIL_SERVER = 'smtp.gmail.com'
MAIL_PORT = 465
MAIL_USE_SSL = True
MAIL_USERNAME = 'hpcaiotserver@gmail.com'
MAIL_PASSWORD = 'HPC&A10T.'
class ProductionConfig(Config): class ProductionConfig(Config):
pass pass
......
APScheduler==3.6.3 APScheduler==3.6.3
bcrypt==3.1.7 bcrypt==3.1.7
blinker==1.4
cffi==1.14.0 cffi==1.14.0
click==7.1.1 click==7.1.1
Flask==1.1.2 Flask==1.1.2
Flask-Mail==0.9.1
itsdangerous==1.1.0 itsdangerous==1.1.0
Jinja2==2.11.2 Jinja2==2.11.2
MarkupSafe==1.1.1 MarkupSafe==1.1.1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment