allow sending raw emails with server='aws'
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.16.1-stable+timestamp.2018.02.26.19.05.23
|
Version 2.16.1-stable+timestamp.2018.03.08.10.23.01
|
||||||
|
|||||||
+17
-1
@@ -775,7 +775,9 @@ class Mail(object):
|
|||||||
if attachments:
|
if attachments:
|
||||||
result = mail.send_mail(
|
result = mail.send_mail(
|
||||||
sender=sender, to=origTo,
|
sender=sender, to=origTo,
|
||||||
subject=to_unicode(subject, encoding), body=to_unicode(text or '', encoding), html=html,
|
subject=to_unicode(subject, encoding),
|
||||||
|
body=to_unicode(text or '', encoding),
|
||||||
|
html=html,
|
||||||
attachments=attachments, **xcc)
|
attachments=attachments, **xcc)
|
||||||
elif html and (not raw):
|
elif html and (not raw):
|
||||||
result = mail.send_mail(
|
result = mail.send_mail(
|
||||||
@@ -785,6 +787,20 @@ class Mail(object):
|
|||||||
result = mail.send_mail(
|
result = mail.send_mail(
|
||||||
sender=sender, to=origTo,
|
sender=sender, to=origTo,
|
||||||
subject=to_unicode(subject, encoding), body=to_unicode(text or '', encoding), **xcc)
|
subject=to_unicode(subject, encoding), body=to_unicode(text or '', encoding), **xcc)
|
||||||
|
elif self.settings.server == 'aws':
|
||||||
|
import boto3
|
||||||
|
from botocore.exceptions import ClientError
|
||||||
|
client = boto3.client('ses')
|
||||||
|
try:
|
||||||
|
raw = payload.as_string()
|
||||||
|
response = client.send_raw_email(RawMessage=raw,
|
||||||
|
Source=sender,
|
||||||
|
Destinations=to)
|
||||||
|
return True
|
||||||
|
except ClientError as e:
|
||||||
|
# we should log this error:
|
||||||
|
# print e.response['Error']['Message']
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
smtp_args = self.settings.server.split(':')
|
smtp_args = self.settings.server.split(':')
|
||||||
kwargs = dict(timeout=self.settings.timeout)
|
kwargs = dict(timeout=self.settings.timeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user