https://www.learnaws.org/2020/12/18/aws-ses-boto3-guide/
plain text
def send_plain_email():
ses_client = boto3.client("ses", region_name="us-west-2")
CHARSET = "UTF-8"
response = ses_client.send_email(
Destination={
"ToAddresses": [
"abhishek@learnaws.org",
],
},
Message={
"Body": {
"Text": {
"Charset": CHARSET,
"Data": "Hello, world!",
}
},
"Subject": {
"Charset": CHARSET,
"Data": "Amazing Email Tutorial",
},
},
Source="abhishek@learnaws.org",
)
html
def send_html_email():
ses_client = boto3.client("ses", region_name="us-west-2")
CHARSET = "UTF-8"
HTML_EMAIL_CONTENT = """
<html>
<head></head>
<h1 style='text-align:center'>This is the heading</h1>
<p>Hello, world</p>
</body>
</html>
"""
response = ses_client.send_email(
Destination={
"ToAddresses": [
"abhishek@learnaws.org",
],
},
Message={
"Body": {
"Html": {
"Charset": CHARSET,
"Data": HTML_EMAIL_CONTENT,
}
},
"Subject": {
"Charset": CHARSET,
"Data": "Amazing Email Tutorial",
},
},
Source="abhishek@learnaws.org",
)