Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Python and Mailchimp to send an email?

I have been reading a lot on the Internet to know how I can use Python to send emails using mailchimp API. It seems that the website is so complected and doesn't have any example.

Please, could you guide me to any example including a Python use?

What I tried so far:

  • I installed the library from pip using: pip install mailchimp;

  • I have created the campain;

  • I have created the lists;

But yet, I couldn't know how to send the emails programmatically.

like image 774
Marco Dinatsoli Avatar asked Dec 15 '22 15:12

Marco Dinatsoli


1 Answers

If you want to trigger a campaign see:

https://apidocs.mailchimp.com/api/2.0/campaigns/send.php

The typical module mailchimp at pypi supports it as followed.

from mailchimp import Mailchimp
mailchimp = Mailchimp(api_key)
mailchimp.campaigns.send(campaign_id)

Sourcecode at: https://bitbucket.org/mailchimp/mailchimp-api-python/src/32ed2394d6b49d7551089484221fa3ee019bee37/mailchimp.py?at=master

Hope it helps.

Cheers, mrcrgl

like image 137
mrcrgl Avatar answered Dec 30 '22 01:12

mrcrgl