def duplicate_payment_sender(sender, instance=None, user=None, billingcycle=None, **kwargs):
    membership = billingcycle.membership
    to = [membership.billing_email()]
    email_body = render_to_string('membership/duplicate_payment_mail.txt', {
        'membership' : membership,
        'billingcycle' : billingcycle,
        'payment': instance,
        'user': user
    })
    email = EmailMessage(_('Duplicate payment'),
                             email_body,
                             settings.BILLING_FROM_EMAIL,
                             to,
                             [settings.BILLING_CC_EMAIL],
                             headers={'CC': settings.BILLING_CC_EMAIL})
    connection = mail.get_connection()
    connection.send_messages([email])
    logger.info(u'A duplicate payment notice email sent to %s (%s) by %s' % (unicode(membership),
                                                               membership.billing_email(),
                                                               user))
Email to bill payer due to duplicate payment
dataset/ETHPy150Open kapsiry/sikteeri/membership/email_utils.py/duplicate_payment_sender