soham navadiya
New Member
Is there any lib for mailwizz in python like mailwizz-php-sdk? How to send mail using mailwizz from my project?
Somthing like belowOk, Thanks. Waiting for your response.
import http.client
conn = http.client.HTTPConnection("yourdomain,com")
headers = {
'X-MW-PUBLIC-KEY': "PUBLIC-KEY",
'X-MW-TIMESTAMP': "TIMESTAMP",
'Cache-Control': "no-cache"
}
conn.request("GET", "api,lists", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import http.client
import time
conn = http.client.HTTPConnection("139.59.4.213/mailwizz/api/index.php")
_tim = str(time.time())
headers = {
'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
'X-MW-TIMESTAMP': _tim,
'Cache-Control': "no-cache"
}
conn.request("GET", "api/lists", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Traceback (most recent call last):
File "mailwizzconnection.py", line 13, in <module>
conn.request("GET", "api/lists", headers=headers)
File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 936, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/home/soham/anaconda3/lib/python3.6/socket.py", line 704, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/home/soham/anaconda3/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
import http.client
import time
conn = http.client.HTTPConnection("139,59,4,213")
headers = {
'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
'X-MW-TIMESTAMP': str(time.time())
}
conn.request("GET", "mailwizz,api,index.php,lists", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
(venv) soham@soham:~/PycharmProjects/logic$ python3 mailwizz.py
[]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 139.59.4.213 Port 80</address>
</body></html>
import http.client
import time
conn = http.client.HTTPConnection("139.59.4.213")
_tim = str(time.time())
headers = {
'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
'X-MW-TIMESTAMP': _tim,
'Cache-Control': "no-cache"
}
conn.request("GET", "/mailwizz/api/index.php", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import http.client
import time
conn = http.client.HTTPConnection("139.59.4.213")
headers = {
'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
'X-MW-TIMESTAMP': str(time.time())
}
conn.request("GET", "mailwizz/api/index.php/lists", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
I think you used python 2 and http.client work on python 3.@majid1f
somehow http.client won't work in mycase. I installed requests lib and use it. Now it is working fine. @twisted1919 Is there any API endpoint documentation in mailwizz where I can refer all endpoint.