def unsubscribe_cm_subscribers(list_id, emails): ''' Unsubscribes all passed-in email addresses from a specified Campaign Monitor list. ''' logger.info("Begin unsubscribing people from list {}".format(list_id)) unsubscribed = [] for email in emails: subscriber = Subscriber(settings.CAMPAIGN_MONITOR_AUTH, list_id, email) subscriber.unsubscribe() unsubscribed.append(email) logger.info("Done unsubscribing people from list {}".format(list_id)) return unsubscribed
def delete_cm_subscriber(sender, instance=None, **kwargs): """Delete the subscriber from the campaign monitor list """ (name, email) = get_name_email(instance) if email: try: list_map = ListMap.objects.get(group=instance.group) list_id = list_map.list_id list = List(list_id) if list: subscriber_obj = Subscriber(list_id, email) try: subscriber_obj.unsubscribe() except: pass except ListMap.DoesNotExist: pass
def delete_cm_subscriber(sender, instance=None, **kwargs): """Delete the subscriber from the campaign monitor list """ from tendenci.apps.base.utils import validate_email (name, email) = get_name_email(instance) if email and validate_email(email): try: list_map = ListMap.objects.get(group=instance.group) list_id = list_map.list_id alist = List(auth, list_id) if alist: subscriber_obj = Subscriber(auth, list_id, email) try: subscriber_obj.unsubscribe() except: pass except ListMap.DoesNotExist: pass
def delete_cm_subscriber(sender, instance=None, **kwargs): """Delete the subscriber from the campaign monitor list """ from django.core.validators import email_re (name, email) = get_name_email(instance) if email and email_re.match(email): try: list_map = ListMap.objects.get(group=instance.group) list_id = list_map.list_id list = List(list_id) if list: subscriber_obj = Subscriber(list_id, email) try: subscriber_obj.unsubscribe() except: pass except ListMap.DoesNotExist: pass