Created
March 31, 2017 07:34
-
-
Save shredding/934bd5a66f3f32396bdc4f43ab162e98 to your computer and use it in GitHub Desktop.
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
import mandrill | |
API_KEY = 'your_api_key' | |
def send_mail(template_name, email_to, context): | |
mandrill_client = mandrill.Mandrill(API_KEY) | |
message = { | |
'to': [], | |
'global_merge_vars': [] | |
} | |
for em in email_to: | |
message['to'].append({'email': em}) | |
for k, v in context.iteritems(): | |
message['global_merge_vars'].append( | |
{'name': k, 'content': v} | |
) | |
mandrill_client.messages.send_template(template_name, [], message) | |
send_mail('your-template-name-in-mandrill', ["[email protected]"], context={'title': "Ms.", 'first_name': 'Sherry'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment