AWS working on localhost in debug mode
This commit is contained in:
31
rowers/emails.py
Normal file
31
rowers/emails.py
Normal 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
|
||||
Reference in New Issue
Block a user