Fatih Degirmenci | c2a4601 | 2019-09-30 12:07:45 +0200 | [diff] [blame] | 1 | from threading import Thread |
| 2 | |
| 3 | from flask import current_app |
| 4 | from flask_mail import Message |
| 5 | from app import mail |
| 6 | |
| 7 | # TODO: enable threading |
| 8 | |
| 9 | def send_async_email(app, msg): |
| 10 | with app.app_context(): |
| 11 | mail.send(msg) |
| 12 | |
| 13 | def send_email(subject, recipients, email_body_html): |
| 14 | msg = Message(subject, |
| 15 | recipients=[recipients], |
| 16 | html=email_body_html, |
| 17 | sender=('Nordix Open Labs', 'noreply@nordix.org')) |
| 18 | |
| 19 | # Thread(target=send_async_email, args=(app, msg)).start() |
| 20 | mail.send(msg) |
| 21 | |
Fatih Degirmenci | 594a58d | 2019-10-01 12:53:53 +0000 | [diff] [blame] | 22 | def notify_admins(subject, user_identifier): |
| 23 | msg = Message(subject, |
| 24 | recipients=['fdegir@gmail.com'], |
| 25 | sender=('Nordix Open Labs', 'noreply@nordix.org')) |
| 26 | |
| 27 | msg.body = 'New user mail address is ' + user_identifier |
| 28 | mail.send(msg) |
| 29 | |
Fatih Degirmenci | c2a4601 | 2019-09-30 12:07:45 +0200 | [diff] [blame] | 30 | #def send_email(user, template): |
| 31 | # send_email('Welcome to Nordix Labs!', |
| 32 | # recipients=[user.email], |
| 33 | # html=template) |