Changeset - 3b6c157e828e
[Not reviewed]
default
0 1 0
Dennis Fink - 10 years ago 2015-03-07 18:40:19
dennis.fink@c3l.lu
Send membership messages to multiple addresses
1 file changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
ennstatus/root/functions.py
Show inline comments
 
@@ -4,17 +4,12 @@ from flask_mail import Mail, Message
 

	
 
from ennstatus.status.functions import mail
 

	
 

	
 
def send_membership_mail(form):
 
    try:
 
        msg = Message('New membership application', sender='ennstatus@enn.lu')
 

	
 
        recipient = current_app.config['ENNSTATUS_MEMBERSHIP_MAIL']
 
        msg.add_recipient(recipient)
 

	
 
        body = render_template('root/membership_mail.txt',
 
                               username=form.username.data,
 
                               email=form.email.data,
 
                               membership=form.membership.data,
 
                               c3l=form.c3l.data,
 
                               firstname=form.firstname.data,
 
@@ -22,22 +17,27 @@ def send_membership_mail(form):
 
                               street=form.street.data,
 
                               zip=form.zip.data,
 
                               city=form.city.data,
 
                               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,
 
                                                               always_trust=True))
 
            current_app.logger.debug('After encryption')
 
            current_app.logger.debug(body)
 
        msg.body = body
 

	
 
        mail.send(msg)
 
                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
0 comments (0 inline, 0 general)