Skip to content
Snippets Groups Projects
Verified Commit 5300cd91 authored by nd's avatar nd
Browse files

do not fail if mail could not be sent, closes #9

parent 87882cc2
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<label for="user-password1">New Password</label> <label for="user-password1">New Password</label>
<input type="password" class="form-control" id="user-password1" name="password1" required="required" tabindex = "2"> <input type="password" class="form-control" id="user-password1" name="password1" required="required" tabindex = "2">
<small class="form-text text-muted"> <small class="form-text text-muted">
At least 8 characters, no other special requirements. But please don't be stupid and use a password manager. At least 8 and at most 256 characters, no other special requirements. But please don't be stupid and use a password manager.
</small> </small>
</div> </div>
<div class="form-group col-12"> <div class="form-group col-12">
......
...@@ -145,6 +145,7 @@ def send_passwordreset(loginname): ...@@ -145,6 +145,7 @@ def send_passwordreset(loginname):
send_mail(user.mail, msg) send_mail(user.mail, msg)
def send_mail(to_address, msg): def send_mail(to_address, msg):
try:
server = smtplib.SMTP(host=current_app.config['MAIL_SERVER'], port=current_app.config['MAIL_PORT']) server = smtplib.SMTP(host=current_app.config['MAIL_SERVER'], port=current_app.config['MAIL_PORT'])
if current_app.config['MAIL_USE_STARTTLS']: if current_app.config['MAIL_USE_STARTTLS']:
server.starttls() server.starttls()
...@@ -155,3 +156,7 @@ def send_mail(to_address, msg): ...@@ -155,3 +156,7 @@ def send_mail(to_address, msg):
msg['Message-ID'] = email.utils.make_msgid() msg['Message-ID'] = email.utils.make_msgid()
server.send_message(msg) server.send_message(msg)
server.quit() server.quit()
return True
except SMTPException:
flash('Mail to "{}" could not be sent!'.format(to_address))
return False
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment