Created
May 21, 2015 14:43
-
-
Save chrisdev/46bf51de3919ab56b8a0 to your computer and use it in GitHub Desktop.
sent email with on mandrill with python
This file contains hidden or 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
# install | |
# ------- | |
pip install mandrill | |
# sending the email | |
# ---------- | |
import mandrill | |
API_KEY = 'valid_api_key' | |
def send_mail(template_name, email_to): | |
mandrill_client = mandrill.Mandrill(API_KEY) | |
message = { | |
'to': [] | |
} | |
for em in email_to: | |
message['to'].append({'email': em}) | |
mandrill_client.messages.send_template(template_name, [], message) | |
if __name__ == '__main__': | |
email_list = ['[email protected]', '[email protected]',] | |
for email in email_list: | |
send_mail(template_name='newsletter-confirm-subscription', [email]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment