code: def announcement_posted_email(request, obj, send_all=False):
      
  
      if settings.EMAIL_ANNOUNCEMENTS:
          subject = "Announcement: {}".format(obj.title)
          if send_all:
              users = User.objects.all()
          else:
              users = User.objects.filter(receive_news_emails=True)
  
          send_groups = obj.groups.all()
          emails = []
          users_send = []
          for u in users:
              if len(send_groups) == 0:
                  # no groups, public.
                  em = u.emails.first() if u.emails.count() >= 1 else u.tj_email
                  if em:
                      emails.append(em)
                  users_send.append(u)
              else:
                  # specific to a group
                  user_groups = u.groups.all()
                  if any(i in send_groups for i in user_groups):
                      # group intersection exists
                      em = u.emails.first() if u.emails.count() >= 1 else u.tj_email
                      if em:
                          emails.append(em)
                      users_send.append(u)
  
          logger.debug(users_send)
          logger.debug(emails)
  
          if not settings.PRODUCTION and len(emails) > 3:
              raise exceptions.PermissionDenied("You're about to email a lot of people, and you aren't in production!")
              return
  
          base_url = request.build_absolute_uri(reverse('index'))
          url = request.build_absolute_uri(reverse('view_announcement', args=[obj.id]))
          data = {"announcement": obj, "info_link": url, "base_url": base_url}
          email_send_bcc("announcements/emails/announcement_posted.txt", "announcements/emails/announcement_posted.html", data, subject, emails)
          messages.success(request, "Sent email to {} users".format(len(users_send)))
      else:
          logger.debug("Emailing announcements disabled")
docs: Send a notification posted email.
  
      obj: The announcement object