Sending HTML email using Python

前端 未结 10 1259
小鲜肉
小鲜肉 2020-11-22 04:57

How can I send the HTML content in an email using Python? I can send simple text.

10条回答
  •  迷失自我
    2020-11-22 05:21

    Here is my answer for AWS using boto3

        subject = "Hello"
        html = "Hello Consumer"
    
        client = boto3.client('ses', region_name='us-east-1', aws_access_key_id="your_key",
                          aws_secret_access_key="your_secret")
    
    client.send_email(
        Source='ACME ',
        Destination={'ToAddresses': [email]},
        Message={
            'Subject': {'Data': subject},
            'Body': {
                'Html': {'Data': html}
            }
        }
    

提交回复
热议问题