def send_email(recipient, subject, message, fail_silently): # A little safety net when debugging if settings.DEBUG: recipient = settings.EMAIL_ADDRESS note = None success = False try: send_mail(subject, message, settings.EMAIL_ADDRESS, [recipient]) success = True except: note = traceback.format_exc() if fail_silently: pass raise finally: member = None try: members = Member.objects.filter(user__email=recipient) if len(members) == 1: member = members[0] except: pass try: log = SentEmailLog(member=member, recipient=recipient, subject=subject, success=success) if note: log.note = note log.save() except: pass
def send_email(recipient, subject, message, fail_silently): # A little safety net when debugging if settings.DEBUG: recipient = settings.EMAIL_ADDRESS success = False try: send_mail(subject, message, settings.EMAIL_ADDRESS, [recipient], fail_silently=fail_silently) success = True finally: try: log = SentEmailLog(recipient=recipient, subject=subject, success=success) log.save() except: pass
def send_email(recipient, subject, message, fail_silently): # A little safety net when debugging if settings.DEBUG: recipient = settings.EMAIL_ADDRESS note = None success = False try: send_mail(subject, message, settings.EMAIL_ADDRESS, [recipient]) success = True except: note = traceback.format_exc() if fail_silently: pass raise finally: try: log = SentEmailLog(recipient=recipient, subject=subject, success=success) if note: log.note = note log.save() except: pass
def send_email(recipient, subject, message, fail_silently): # A little safety net when debugging if settings.DEBUG: recipient = settings.EMAIL_ADDRESS note = None success = False try: msg = EmailMessage(subject, message, settings.EMAIL_ADDRESS, [recipient]) #msg.content_subtype = "html" # Main content is now text/html msg.send() success = True except: note = traceback.format_exc() if fail_silently: pass raise finally: member = None try: members = Member.objects.filter(user__email=recipient) if len(members) == 1: member = members[0] except: pass try: log = SentEmailLog(member=member, recipient=recipient, subject=subject, success=success) if note: log.note = note log.save() except: pass