Update smtp.py

This commit is contained in:
Namhyeon Go 2024-03-01 04:36:04 +09:00 committed by GitHub
parent 493d5dcb5f
commit e8c9f3ceb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

12
smtp.py
View File

@ -98,16 +98,22 @@ class CaterpillarSMTPServer(SMTPServer):
to = v to = v
# build a data # build a data
_, raw_data = jsonrpc2_encode('relay_sendmail', { proxy_data = {
'headers': {
"User-Agent": "php-httpproxy/0.1.5 (Client; Python " + python_version() + "; Caterpillar; abuse@catswords.net)",
},
'data': {
"to": to, "to": to,
"from": mailfrom, "from": mailfrom,
"subject": subject, "subject": subject,
"message": data.decode('utf-8') "message": data.decode('utf-8')
}) }
}
_, raw_data = jsonrpc2_encode('relay_sendmail', proxy_data['data'])
# send HTTP POST request # send HTTP POST request
try: try:
response = requests.post(server_url, data=raw_data, auth=auth) response = requests.post(server_url, headers=proxy_data['headers'], data=raw_data, auth=auth)
if response.status_code == 200: if response.status_code == 200:
type, id, method, rpcdata = jsonrpc2_decode(response.text) type, id, method, rpcdata = jsonrpc2_decode(response.text)
if rpcdata['success']: if rpcdata['success']: