-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsend_sync_batch.py
More file actions
33 lines (27 loc) · 941 Bytes
/
send_sync_batch.py
File metadata and controls
33 lines (27 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Send a batch of emails synchronously — no async/await required.
Up to 500 messages can be submitted in a single batch call.
Run:
poetry run python examples/sync/outbound_messages/send_sync_batch.py
python examples/sync/outbound_messages/send_sync_batch.py # with venv active
"""
import postmark
SENDER = "sender@example.com"
messages = [
postmark.Email(
sender=SENDER,
to="alice@example.com", # change to real addresses
subject="Hello Alice",
text_body="Hi Alice, sent via postmark.sync.",
),
postmark.Email(
sender=SENDER,
to="bob@example.com",
subject="Hello Bob",
text_body="Hi Bob, sent via postmark.sync.",
),
]
with postmark.sync.ServerClient("xxx-YOUR-SERVER-TOKEN-xxxx-xxxxxxx") as client:
results = client.outbound.send_batch(messages)
for r in results:
print(f"Message ID: {r.message_id} Accepted: {r.success}")