<s> from django . conf import settings <EOL> from django . core . mail import EmailMultiAlternatives <EOL> from django . template . loader import render_to_string <EOL> from django . utils . html import strip_tags <EOL> from django . contrib . sites . models import Site <EOL> def send_email ( to , kind , ** kwargs ) : <EOL> current_site = Site . objects . get_current ( ) <EOL> ctx = { <EOL> "<STR_LIT>" : current_site , <EOL> "<STR_LIT>" : settings . STATIC_URL , <EOL> } <EOL> ctx . update ( kwargs . get ( "<STR_LIT>" , { } ) ) <EOL> subject = "<STR_LIT>" % ( <EOL> current_site . name , <EOL> render_to_string ( "<STR_LIT>" % kind , ctx ) . strip ( ) <EOL> ) <EOL> message_html = render_to_string ( "<STR_LIT>" % kind , ctx ) <EOL> message_plaintext = strip_tags ( message_html ) <EOL> from_email = settings . DEFAULT_FROM_EMAIL <EOL> email = EmailMultiAlternatives ( subject , message_plaintext , from_email , to ) <EOL> email . attach_alternative ( message_html , "<STR_LIT>" ) <EOL> email . send ( ) </s>
