mirror of
https://github.com/optim-enterprises-bv/Mailu-OIDC.git
synced 2025-11-02 19:17:57 +00:00
Implement welcome emails, fixes #107
This commit is contained in:
@@ -42,7 +42,10 @@ default_config = {
|
|||||||
'WEBMAIL': 'none',
|
'WEBMAIL': 'none',
|
||||||
'AUTH_RATELIMIT': '10/minute;1000/hour',
|
'AUTH_RATELIMIT': '10/minute;1000/hour',
|
||||||
'RATELIMIT_STORAGE_URL': 'redis://redis',
|
'RATELIMIT_STORAGE_URL': 'redis://redis',
|
||||||
'DISABLE_STATISTICS': 'False'
|
'DISABLE_STATISTICS': 'False',
|
||||||
|
'WELCOME': 'False',
|
||||||
|
'WELCOME_SUBJECT': 'Dummy welcome topic',
|
||||||
|
'WELCOME_BODY': 'Dummy welcome body'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load configuration from the environment if available
|
# Load configuration from the environment if available
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ from mailu.ui import ui, forms, access
|
|||||||
|
|
||||||
import flask
|
import flask
|
||||||
import flask_login
|
import flask_login
|
||||||
import smtplib
|
|
||||||
|
|
||||||
from email.mime import text
|
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
|
|
||||||
@@ -50,20 +48,13 @@ def services():
|
|||||||
@ui.route('/announcement', methods=['GET', 'POST'])
|
@ui.route('/announcement', methods=['GET', 'POST'])
|
||||||
@access.global_admin
|
@access.global_admin
|
||||||
def announcement():
|
def announcement():
|
||||||
from_address = '{}@{}'.format(
|
|
||||||
app.config['POSTMASTER'], app.config['DOMAIN'])
|
|
||||||
form = forms.AnnouncementForm()
|
form = forms.AnnouncementForm()
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
with smtplib.SMTP('smtp', port=10025) as smtp:
|
for user in models.User.query.all():
|
||||||
for recipient in [user.email for user in models.User.query.all()]:
|
user.sendmail(form.announcement_subject.data,
|
||||||
msg = text.MIMEText(form.announcement_body.data)
|
form.announcement_body.data)
|
||||||
msg['Subject'] = form.announcement_subject.data
|
|
||||||
msg['From'] = from_address
|
|
||||||
msg['To'] = recipient
|
|
||||||
smtp.sendmail(from_address, [recipient], msg.as_string())
|
|
||||||
# Force-empty the form
|
# Force-empty the form
|
||||||
form.announcement_subject.data = ''
|
form.announcement_subject.data = ''
|
||||||
form.announcement_body.data = ''
|
form.announcement_body.data = ''
|
||||||
flask.flash('Your announcement was sent', 'success')
|
flask.flash('Your announcement was sent', 'success')
|
||||||
return flask.render_template('announcement.html', form=form,
|
return flask.render_template('announcement.html', form=form)
|
||||||
from_address=from_address)
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ def user_create(domain_name):
|
|||||||
user.set_password(form.pw.data)
|
user.set_password(form.pw.data)
|
||||||
db.session.add(user)
|
db.session.add(user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
user.send_welcome()
|
||||||
flask.flash('User %s created' % user)
|
flask.flash('User %s created' % user)
|
||||||
return flask.redirect(
|
return flask.redirect(
|
||||||
flask.url_for('.user_list', domain_name=domain.name))
|
flask.url_for('.user_list', domain_name=domain.name))
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ RECIPIENT_DELIMITER=+
|
|||||||
DMARC_RUA=admin
|
DMARC_RUA=admin
|
||||||
DMARC_RUF=admin
|
DMARC_RUF=admin
|
||||||
|
|
||||||
|
# Weclome email, enable and set a topic and body if you wish to send welcome
|
||||||
|
# emails to all users.
|
||||||
|
WELCOME=false
|
||||||
|
WELCOME_SUBJECT=Welcome to your new email account
|
||||||
|
WELCOME_BODY=Welcome to your new email account, if you can read this, then it is configured properly!
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# Web settings
|
# Web settings
|
||||||
###################################
|
###################################
|
||||||
|
|||||||
Reference in New Issue
Block a user