def send_reminder(pia_request, overdue_date=None, **kwargs): """ Send a reminder message to the Authority. """ template= kwargs.get('email_template', 'emails/reminder_overdue.txt') if overdue_date is None: overdue_date= datetime.strftime(pia_request.created, '%d.%m.%Y') authority= pia_request.authority try: email_to= authority.email except: print AppMessage('AuthEmailNotFound', value=(authority.slug, authority.name,)).message return None email_from= email_from_name(pia_request.user.get_full_name(), id=pia_request.id, delimiter='.') message_subject= get_message_subject('overdue', number=pia_request.pk, date=overdue_date) message_content= render_to_string(template, { 'email_to': email_to, 'request_id': str(pia_request.pk), 'request_date': overdue_date, 'authority': authority, 'info_email': 'info@%s' % get_domain_name()}) message_request= EmailMessage(message_subject, message_content, DEFAULT_FROM_EMAIL, [email_to], headers = {'Reply-To': email_from}) try: # sending the message to the Authority, check if it doesn't fail. message_request.send(fail_silently=False) except Exception as e: print >> sys.stderr, '[%s] %s' % (datetime.now().isoformat(), AppMessage('MailSendFailed').message % e) return None return True # Success.