<s> from django . conf import settings <EOL> from django . core . mail import EmailMessage <EOL> from django . template import Context <EOL> from django . template . loader import render_to_string <EOL> from django . contrib . sites . models import Site <EOL> from comrade . mail . signals import email_sent <EOL> def direct_to_email ( template , recipient_list , extra_context = None , <EOL> from_email = None , subject_template = None ) : <EOL> """<STR_LIT>""" <EOL> extra_context = extra_context or { } <EOL> context = Context ( extra_context ) <EOL> context [ '<STR_LIT>' ] = Site . objects . get_current ( ) <EOL> if not subject_template : <EOL> subject = render_to_string ( <EOL> '<STR_LIT>' % template , context ) . strip ( '<STR_LIT:\n>' ) <EOL> message = render_to_string ( '<STR_LIT>' % template , context ) <EOL> email_sent . send ( sender = template , recipient_list = recipient_list , <EOL> from_address = ( from_email or settings . DEFAULT_FROM_EMAIL ) ) <EOL> return EmailMessage ( subject , message , from_email , recipient_list , <EOL> headers = { '<STR_LIT>' : settings . DEFAULT_FROM_EMAIL } ) . send ( ) </s>
