CLI for common mailchimp functions.
Requires MAILCHIMP_API_KEY
to be set as an environmental variable.
Install the package:
pip install git+https://github.com/mysociety/mysoc-mailchimp
To see options:
python -m mysoc_mailchimp --help
python -m mysoc_mailchimp wordpress-upload --url https://docs.google.com/document/d/1CYfTKBwP2PgPcV0HasjbuXuh599GbATKUMVFBnfV_gk/edit
Can be used to automate moving a mySociety blog post into mailchimp.
python -m mysoc_mailchimp convert-blog --url 'https://www.mysociety.org/2024/10/02/and-were-off-our-whofundsthem-project-has-restarted/' \
--list "mySociety Newsletters" \
--segment "Interest: Democracy" \
--template "mySociety auto-blog" \
--from-name "mySociety" \
--test-email "[email protected]" \
--add-campaign
You can then send after review (which will be scheduled for roughly 10-20 minutes later so it can be reversed):
msmc send --campaign-id [new_campaign_id]
python -m mysoc_mailchimp twfy-config --blog-url https://www.mysociety.org/2024/10/02/and-were-off-our-whofundsthem-project-has-restarted/ > config.txt