Last active
January 24, 2019 06:13
-
-
Save NazmusShakib/6af08200dcd46ea47fa7470341906e02 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 email.mime.text import MIMEText | |
from email.mime.application import MIMEApplication | |
from email.mime.multipart import MIMEMultipart | |
import datetime | |
import boto3 | |
client = boto3.client( | |
'ses', | |
region_name = 'us-east-1', | |
aws_access_key_id = 'IUITRERTTUUOI', | |
aws_secret_access_key = '5zfdgsdfg+sd+rtreter87uRd09WbJ87' | |
) | |
message = MIMEMultipart() | |
message['Subject'] = 'SES Test Response' | |
message['From'] = 'SES <[email protected]>' | |
message['To'] = ', '.join(['[email protected]', '[email protected]']) | |
# message body | |
part = MIMEText('Find the attached file below.', 'html') | |
message.attach(part) | |
# attachment | |
attachment_file = 'Report-'+ format(datetime.date.today()) + '.csv' | |
part = MIMEApplication(open(attachment_file, 'rb').read()) | |
part.add_header('Content-Disposition', 'attachment', filename=attachment_file) | |
message.attach(part) | |
response = client.send_raw_email( | |
Source = message['From'], | |
Destinations = ['[email protected]', '[email protected]'], | |
RawMessage = { | |
'Data': message.as_string() | |
} | |
) | |
print (response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment