Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #53 from dutchcoders/develop

fixed issues with boto
  • Loading branch information...
commit 6ba41a4de60317c7c2fed5d1b63430f0a79d2278 2 parents ff276ba + 01bf837
Alice Zoë Bevan–McGregor amcgregor authored
Showing with 16 additions and 11 deletions.
  1. +8 −5 marrow/mailer/__init__.py
  2. +8 −6 marrow/mailer/transport/ses.py
13 marrow/mailer/__init__.py
View
@@ -65,11 +65,14 @@ def __init__(self, config, prefix=None):
warnings.warn("Use of the transport directive is deprecated; use transport.use instead.", DeprecationWarning)
transport_config.use = config.transport
- if 'message' in config and isinstance(config.message, dict):
- self.message_config = Bunch(config.message)
- else:
- self.message_config = Bunch.partial('message', config)
-
+ try:
+ if 'message' in config and isinstance(config.message, dict):
+ self.message_config = Bunch(config.message)
+ else:
+ self.message_config = Bunch.partial('message', config)
+ except ValueError:
+ self.message_config = Bunch()
+
self.Manager = Manager = self._load(manager_config.use if 'use' in manager_config else 'immediate', 'marrow.mailer.manager')
if not Manager:
14 marrow/mailer/transport/ses.py
View
@@ -3,6 +3,7 @@
# TODO: Port: https://github.com/pankratiev/python-amazon-ses-api/blob/master/amazon_ses.py
try:
+ import boto.ses
from boto.ses import SESConnection
except ImportError:
@@ -16,26 +17,27 @@
class AmazonTransport(object): # pragma: no cover
- __slots__ = ('ephemeral', 'id', 'key', 'host', 'connection')
+ __slots__ = ('ephemeral', 'id', 'key', 'region', 'connection')
def __init__(self, config):
self.id = config.get('id')
self.key = config.get('key')
- self.host = config.get('host', "email.us-east-1.amazonaws.com")
+ self.region = config.get('region', "us-east-1")
self.connection = None
def startup(self):
- self.connection = SESConnection(
+ self.connection = boto.ses.connect_to_region(self.region,
aws_access_key_id = self.id,
- aws_secret_access_key = self.key,
- host = self.host
+ aws_secret_access_key = self.key
)
def deliver(self, message):
try:
+ destinations = [r.encode(encoding='utf-8') for r in message.recipients]
+
response = self.connection.send_raw_email(
source = message.author.encode(),
- destinations = message.recipients.encode(),
+ destinations = destinations,
raw_message = str(message)
)
Please sign in to comment.
Something went wrong with that request. Please try again.