socketlabs / socketlabs-python Goto Github PK
View Code? Open in Web Editor NEWSocketLabs Email Delivery Python Client Library
Home Page: https://www.socketlabs.com
License: MIT License
SocketLabs Email Delivery Python Client Library
Home Page: https://www.socketlabs.com
License: MIT License
On unsuccessful injections (e.g. connection error or wrong API-key) a TypeError occurs in that module:
Traceback (most recent call last): File "/usr/scripts/basic.py", line 31, in <module> response = client.send(message) File "/home/pi/.local/lib/python3.7/site-packages/socketlabs/injectionapi/socketlabsclient.py", line 104, in send return self.__send_basic_message(message) File "/home/pi/.local/lib/python3.7/site-packages/socketlabs/injectionapi/socketlabsclient.py", line 130, in __send_basic_message result = InjectionResponseParser.parse(data, response_code) File "/home/pi/.local/lib/python3.7/site-packages/socketlabs/injectionapi/core/injectionresponseparser.py", line 92, in parse injection_response = get_injection_response_dto(response) File "/home/pi/.local/lib/python3.7/site-packages/socketlabs/injectionapi/core/injectionresponseparser.py", line 63, in get_injection_response_dto for item in dct['MessageResults']: TypeError: 'NoneType' object is not iterable
You can test it with your basic send example.
I have the following code snippet that works some of the time, but more often that not results in a traceback indicating KeyError: 'InvalidFromAddress'
I am using python 3.10
def __notifySend(self, to_email: str, from_email: str) -> None:
msg = BasicMessage()
slc = SocketLabsClient(
int(str(os.getenv("SOCKETLABS_SERVER_ID"))),
str(os.getenv("SOCKETLABS_API_KEY"))
)
msg.subject = "Suspected troll found!"
msg.html_body = "<html>Busted!</html>"
msg.plain_text_body = "We got 'im boys!"
msg.from_email_address = EmailAddress(from_email)
msg.to_email_address.append(EmailAddress(to_email))
response = slc.send(msg)
print(response)
return
I am not sure why this would be the case, as the method more or less follows exactly what the documentation suggests, and sometimes it works as expected. I have tested this on two separate known-good email addresses and can confirm that when the code does what it is supposed to, they appear in my inbox as expected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.