Created
July 2, 2021 11:03
-
-
Save samuelcolvin/a5b5cc53255642076067c62904b30670 to your computer and use it in GitHub Desktop.
aioaws SES example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from httpx import AsyncClient | |
from aioaws.ses import SesConfig, SesClient, SesRecipient, SesAttachment | |
async def ses_demo(client: AsyncClient): | |
ses_client = SesClient(client, SesConfig('<access key>', '<secret key>', '<region>')) | |
message_id = await ses_client.send_email( | |
SesRecipient('sende@example.com', 'Sender', 'Name'), | |
'This is the subject', | |
[SesRecipient('recipient@eample.com', 'John', 'Doe')], | |
'this is the plain text body', | |
html_body='<b>This is the HTML body.<b>', | |
bcc=[SesRecipient(...)], | |
attachments=[ | |
SesAttachment(b'this is content', 'attachment-name.txt', 'text/plain'), | |
SesAttachment(Path('foobar.png')), | |
], | |
unsubscribe_link='https:://example.com/unsubscribe', | |
configuration_set='SES configuration set', | |
message_tags={'ses': 'tags', 'go': 'here'}, | |
) | |
print('SES message ID:', message_id) | |
async def main(): | |
async with AsyncClient() as client: | |
await ses_demo(client) | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment