Spaces:
Runtime error
Runtime error
Upload emailer.py
Browse files- emailer.py +4 -1
emailer.py
CHANGED
|
@@ -106,7 +106,10 @@ def _send_via_resend(recipients: list, subject: str, content: str) -> str:
|
|
| 106 |
req = urllib.request.Request(
|
| 107 |
"https://api.resend.com/emails", data=payload, method="POST",
|
| 108 |
headers={"Authorization": f"Bearer {RESEND_API_KEY}",
|
| 109 |
-
"Content-Type": "application/json"
|
|
|
|
|
|
|
|
|
|
| 110 |
try:
|
| 111 |
with urllib.request.urlopen(req, timeout=30) as resp:
|
| 112 |
body = resp.read().decode("utf-8", "ignore")
|
|
|
|
| 106 |
req = urllib.request.Request(
|
| 107 |
"https://api.resend.com/emails", data=payload, method="POST",
|
| 108 |
headers={"Authorization": f"Bearer {RESEND_API_KEY}",
|
| 109 |
+
"Content-Type": "application/json",
|
| 110 |
+
# Resend/Cloudflare reject requests with no User-Agent
|
| 111 |
+
# (403, error code 1010) before they reach the API.
|
| 112 |
+
"User-Agent": "chan-compass/1.0 (+https://huggingface.co/spaces)"})
|
| 113 |
try:
|
| 114 |
with urllib.request.urlopen(req, timeout=30) as resp:
|
| 115 |
body = resp.read().decode("utf-8", "ignore")
|