Changeset - b04afc1298b8
[Not reviewed]
default
0 1 0
Dennis Fink - 10 years ago 2015-03-07 18:48:49
dennis.fink@c3l.lu
Fixed encrypted mail
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
ennstatus/root/functions.py
Show inline comments
 
@@ -20,28 +20,30 @@ def send_membership_mail(form):
 
                               country=form.country.data,
 
                               gpg=form.gpg.data
 
                               )
 

	
 
        recipients = current_app.config['ENNSTATUS_MEMBERSHIP_MAIL']
 
        with mail.connect() as conn:
 
            for recipient in recipients:
 
                msg = Message('New membership application', sender='ennstatus@enn.lu')
 
                msg.add_recipient(recipient)
 
                current_app.logger.debug('Before encryption')
 
                current_app.logger.debug(body)
 
                if current_app.extensions['gnupg']:
 
                    body = str(current_app.extensions['gnupg'].encrypt(body, recipient,
 
                    encrypted_body = str(current_app.extensions['gnupg'].encrypt(body, recipient,
 
                               always_trust=True))
 
                else:
 
                    encrypted_body = None
 
                current_app.logger.debug('After encryption')
 
                current_app.logger.debug(body)
 
                msg.body = body
 
                msg.body = encrypted_body if encrypted_body else body
 
                conn.send(msg)
 
        flash('Application successfully sended!', 'success')
 
    except KeyError:
 
        flash('Internal server error! Please get in touch with us at info@enn.lu!', 'error')
 
        current_app.logger.error('Membership admin not found!')
 
    except AssertionError:
 
        pass
 
    except Exception as e:
 
        flash('Internal server error! Please get in touch with us at info@enn.lu!', 'error')
 
        current_app.logger.error('Unexpected error: %s' % e,
 
                                 exc_info=True)
0 comments (0 inline, 0 general)