Private
Public Access
1
0

AWS working on localhost in debug mode

This commit is contained in:
Sander Roosendaal
2018-03-16 16:08:06 +01:00
parent 4cdb3f4e68
commit ce974ee884
6 changed files with 53 additions and 93 deletions

31
rowers/emails.py Normal file
View File

@@ -0,0 +1,31 @@
from django.core.mail.message import MIMEText
#from email.mime.application import MIMEApplication
from django.core.mail.message import MIMEMultipart
# boto3 email functionality
import boto3
AWS_REGION = "us-west-2"
CHARSET = "UTF-8"
client = boto3.client('ses',region_name=AWS_REGION)
def sendemail(fromaddress,recipients,subjecttext,bodytext,attachment=None):
msg = MIMEMultipart()
msg['Subject'] = subjecttext
msg['From'] = fromaddress
msg['To'] = recipients
part = MIMEText(bodytext)
msg.attach(part)
# if attachment:
# part = MIMEApplication(open(attachment,'rb').read())
# part.add_header('Content-Disposition', 'attachment',
# filename=attachment)
# msg.attach(part)
result = client.send_raw_email(
Source=msg['From'],
Destination=msg['To'],
RawMessage=msg
)
return result