Skip to content

Commit 48cae38

Browse files
added basic_send_with_retry
1 parent db3fc50 commit 48cae38

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import json
2+
import os
3+
4+
from socketlabs.injectionapi import SocketLabsClient
5+
from socketlabs.injectionapi.proxy import Proxy
6+
from socketlabs.injectionapi.message.__imports__ import BasicMessage, EmailAddress
7+
8+
# build the message
9+
message = BasicMessage()
10+
11+
message.subject = "Sending An Email Through A Proxy"
12+
message.html_body = "<html><body>" \
13+
"<h1>Sending An Email Through A Proxy</h1>" \
14+
"<p>This is the Html Body of my message.</p>" \
15+
"</body></html>"
16+
message.plain_text_body = "This is the Plain Text Body of my message."
17+
18+
message.from_email_address = EmailAddress("[email protected]")
19+
message.add_to_email_address("[email protected]")
20+
21+
22+
# get credentials from environment variables
23+
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))
24+
api_key = os.environ.get('SOCKETLABS_INJECTION_API_KEY')
25+
26+
# create the proxy
27+
proxy = Proxy("127.0.0.1", 4433)
28+
29+
# create the client
30+
client = SocketLabsClient(server_id, api_key, proxy)
31+
client.request_timeout = 10
32+
client.number_of_retries = 2
33+
34+
# send the message
35+
response = client.send(message)
36+
37+
print(json.dumps(response.to_json(), indent=2))

0 commit comments

Comments
 (0)