Last active
January 24, 2019 06:13
-
-
Save NazmusShakib/6af08200dcd46ea47fa7470341906e02 to your computer and use it in GitHub Desktop.
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 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 <mahdi@cloudly.io>' | |
message['To'] = ', '.join(['nazmus.shakib@cloudly.io', 'fazlul@cloudly.io']) | |
# 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 = ['nazmus.shakib@cloudly.io', 'fazlul@cloudly.io'], | |
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