diff --git a/ennstatus/root/functions.py b/ennstatus/root/functions.py --- a/ennstatus/root/functions.py +++ b/ennstatus/root/functions.py @@ -29,11 +29,13 @@ def send_membership_mail(form): 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, - always_trust=True)) + 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: