Skip to content

Instantly share code, notes, and snippets.

@shredding
Created March 31, 2017 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shredding/934bd5a66f3f32396bdc4f43ab162e98 to your computer and use it in GitHub Desktop.
Save shredding/934bd5a66f3f32396bdc4f43ab162e98 to your computer and use it in GitHub Desktop.
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', ["customer@email.csv"], context={'title': "Ms.", 'first_name': 'Sherry'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment