X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/42ee328f2c761f8453cd3a858b05410499a7cc9a..64d26c022dc182339b33c3cd8e4ef1978b150573:/src/newsletter/subscribe.py diff --git a/src/newsletter/subscribe.py b/src/newsletter/subscribe.py new file mode 100644 index 000000000..d7a8a2795 --- /dev/null +++ b/src/newsletter/subscribe.py @@ -0,0 +1,21 @@ +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +import requests + + +def subscribe(email, newsletter): + list_id = newsletter.phplist_id + data = { + "email": email, + "emailconfirm": email, + f"list[{list_id}]": "signup", + "htmlemail": 1, + "subscribe": "Subscribe", + } + response = requests.post( + 'https://mailing.mdrn.pl/?p=subscribe', + data=data, + ) + response.raise_for_status() +