Files
service-finder/archive/2026-03-29/root/test_registration_smtp.py
2026-03-30 06:32:22 +00:00

30 lines
823 B
Python

import urllib.request
import urllib.error
import json
import time
email = f"smtp_tester_{int(time.time())}@example.com"
url = "http://localhost:8000/api/v1/auth/register"
payload = {
"email": email,
"password": "TestPassword123!",
"first_name": "Test",
"last_name": "SMTP",
"region_code": "HU",
"lang": "hu"
}
data = json.dumps(payload).encode('utf-8')
req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application/json'})
try:
print(f"Registering: {email}")
resp = urllib.request.urlopen(req, timeout=20.0)
print(f"Status: {resp.status}")
print(f"Response: {resp.read().decode('utf-8')}")
except urllib.error.HTTPError as e:
print(f"HTTPError: {e.code}")
print(f"Response: {e.read().decode('utf-8')}")
except Exception as e:
print(f"Error: {e}")