Last active
January 2, 2020 14:47
-
-
Save lopinho/d5bbd44b51638eccac349998d6cc5dc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from usuarios.models import * | |
from django.conf import settings | |
from django.core.mail import EmailMessage | |
estado = 'BA' | |
destinatarios = ['tatyane@grupobaraka.com.br', 'glaucia@tree.sh'] | |
emails = User.objects.filter(userprofile__localidade__estado__sigla=estado, userprofile__ativo_para_o_site=True).values_list('email', flat=True) | |
message = EmailMessage('Emails do estado %s' % estado, 'em anexo', settings.EMAIL_HOST_USER, destinatarios) | |
message.attach('emails_%s.txt' % estado, "\n".join(emails), 'text/plain') | |
message.send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment