Imports at the start.
[wolnelektury.git] / src / newsletter / subscribe.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 import requests
5
6
7 def subscribe(email, newsletter):
8     list_id = newsletter.phplist_id
9     data = {
10         "email": email,
11         "emailconfirm": email,
12         f"list[{list_id}]": "signup",
13         "htmlemail": 1,
14         "subscribe": "Subscribe",
15     }
16     response = requests.post(
17         'https://mailing.mdrn.pl/?p=subscribe',
18         data=data,
19     )
20     response.raise_for_status()
21