mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			18 lines
		
	
	
		
			585 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			585 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from flask import current_app, render_template
 | 
						|
from flask_mail import Message
 | 
						|
from . import mail
 | 
						|
from .decorators import background
 | 
						|
 | 
						|
 | 
						|
def create_message(recipient, subject, template, **kwargs):
 | 
						|
    msg = Message('{} {}'.format(current_app.config['NOPAQUE_MAIL_SUBJECT_PREFIX'], subject), recipients=[recipient])  # noqa
 | 
						|
    msg.body = render_template('{}.txt.j2'.format(template), **kwargs)
 | 
						|
    msg.html = render_template('{}.html.j2'.format(template), **kwargs)
 | 
						|
    return msg
 | 
						|
 | 
						|
 | 
						|
@background
 | 
						|
def send(msg, *args, **kwargs):
 | 
						|
    with kwargs['app'].app_context():
 | 
						|
        mail.send(msg)
 |