def mass_mailing_recipients():
    """
    Returns iterable of all mass email recipients.
    Default behavior will be to return list of all active users' emails.
    This can be changed by providing callback in settings return some other list of users,
    when user emails are stored in many, non default models.
    To accomplish that add constant MASS_EMAIL_RECIPIENTS to settings. It should contain path to function, e.g.
    >>> MASS_EMAIL_RECIPIENTS = 'emailtemplates.helpers.mass_mailing_recipients'

    :rtype iterable
    """
    if hasattr(settings, 'MASS_EMAIL_RECIPIENTS'):
        callback_name = settings.MASS_EMAIL_RECIPIENTS.split('.')
        module_name = '.'.join(callback_name[:-1])
        func_name = callback_name[-1]
        module = import_module(module_name)
        func = getattr(module, func_name, lambda: [])
        return func()
    User = get_user_model()
    if hasattr(User, 'is_active') and hasattr(User, 'email'):
        filtered_users = User.objects.filter(is_active=True).exclude(email__isnull=True).exclude(email__exact='')
        return filtered_users.values_list('email', flat=True).distinct()
    return []
Returns iterable of all mass email recipients.
    Default behavior will be to return list of all active users' emails.
    This can be changed by providing callback in settings return some other list of users,
    when user emails are stored in many, non default models.
    To accomplish that add constant MASS_EMAIL_RECIPIENTS to settings. It should contain path to function, e.g.
    >>> MASS_EMAIL_RECIPIENTS = 'emailtemplates.helpers.mass_mailing_recipients'

    :rtype iterable