title: Sending emails using django-SES (Amazon SES)
body: <p>I've been trying to configure the django-SES services to send outgoing emails and am not sure what is wrong here. Am receving a strange error message, </p>
  
  <p>settings.py</p>
  
  <pre><code># Email Configuration using Amazon SES Services
  EMAIL_BACKEND = 'django_ses.SESBackend'
  
  # These are optional -- if they're set as environment variables they won't
  # need to be set here as well
  AWS_SES_ACCESS_KEY_ID = 'xxxxxxx'
  AWS_SES_SECRET_ACCESS_KEY = 'xxxxxxxxxxxxx'
  
  # Additionally, you can specify an optional region, like so:
  AWS_SES_REGION_NAME = 'us-east-1'
  AWS_SES_REGION_ENDPOINT = 'email-smtp.us-east-1.amazonaws.com'
  </code></pre>
  
  <p>In my design, am inserting all emails into a table and then using celery task to go through all pending emails and firing them. </p>
  
  <p>here is my tasks.py</p>
  
  <pre><code>@task(name='common_lib.send_notification', ignore_result=True)
  @transaction.commit_manually
  def fire_pending_email():
      try:
          Notification        = get_model('common_lib', 'Notification')
          NotificationEmail   = get_model('common_lib', 'NotificationEmail')
  
          pending_notifications=Notification.objects.values_list('id', flat=True).filter(status=Notification.STATUS_PENDING)
          for email in NotificationEmail.objects.filter(notification__in=pending_notifications):
              msg = EmailMultiAlternatives(email.subject, email.text_body, 'noreply@xx.com.xx', [email.send_to, ])
              if email.html_body:
                  msg.attach_alternative(email.html_body, "text/html")
              msg.send()
  
          transaction.commit()
          return 'Successful'
  
      except Exception as e:
          transaction.rollback()
          logging.error(str(e))
      finally:
          pass
  </code></pre>
  
  <p>yet in the celery debug console am seeing the following error</p>
  
  <pre><code>    [2012-11-13 11:45:28,061: INFO/MainProcess] Got task from broker: common_lib.send_notification[4dc71dee-fc7c-4ddc-a02c-4097c73e4384]
  [2012-11-13 11:45:28,069: DEBUG/MainProcess] Mediator: Running callback for task: common_lib.send_notification[4dc71dee-fc7c-4ddc-a02c-4097c73e4384]
  [2012-11-13 11:45:28,069: DEBUG/MainProcess] TaskPool: Apply &lt;function trace_task_ret at 0x9f38a3c&gt; (args:('common_lib.send_notification', '4dc71dee-fc7c-4ddc-a02c-4097c73e4384', [], {}, {'retries': 0, 'is_eager': False, 'task': 'common_lib.send_notification', 'group': None, 'eta': None, 'delivery_info': {'priority': None, 'routing_key': u'celery', 'exchange': u'celery'}, 'args': [], 'expires': None, 'callbacks': None, 'errbacks': None, 'hostname': 'ubuntu', 'kwargs': {}, 'id': '4dc71dee-fc7c-4ddc-a02c-4097c73e4384', 'utc': True}) kwargs:{})
  [2012-11-13 11:45:28,077: DEBUG/MainProcess] Task accepted: common_lib.send_notification[4dc71dee-fc7c-4ddc-a02c-4097c73e4384] pid:8256
  [2012-11-13 11:45:28,097: DEBUG/MainProcess] (0.001) SELECT `common_lib_notification_email`.`id`, `common_lib_notification_email`.`notification_id`, `common_lib_notification_email`.`send_to`, `common_lib_notification_email`.`template`, `common_lib_notification_email`.`subject`, `common_lib_notification_email`.`html_body`, `common_lib_notification_email`.`text_body` FROM `common_lib_notification_email` WHERE `common_lib_notification_email`.`notification_id` IN (SELECT U0.`id` FROM `common_lib_notification` U0 WHERE U0.`status` = 'P' ); args=(u'P',)
  [2012-11-13 11:45:28,103: DEBUG/MainProcess] Method: POST
  [2012-11-13 11:45:28,107: DEBUG/MainProcess] Path: /
  [2012-11-13 11:45:28,107: DEBUG/MainProcess] Data: Action=GetSendQuota
  [2012-11-13 11:45:28,107: DEBUG/MainProcess] Headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
  [2012-11-13 11:45:28,109: DEBUG/MainProcess] Host: email-smtp.us-east-1.amazonaws.com
  [2012-11-13 11:45:28,109: DEBUG/MainProcess] establishing HTTPS connection: host=email-smtp.us-east-1.amazonaws.com, kwargs={}
  [2012-11-13 11:45:28,109: DEBUG/MainProcess] Token: None
  [2012-11-13 11:45:28,702: DEBUG/MainProcess] wrapping ssl socket; CA certificate file=/home/mo/projects/garageenv/local/lib/python2.7/site-packages/boto/cacerts/cacerts.txt
  [2012-11-13 11:45:29,385: DEBUG/MainProcess] validating server certificate: hostname=email-smtp.us-east-1.amazonaws.com, certificate hosts=[u'email-smtp.us-east-1.amazonaws.com']
  [2012-11-13 11:45:39,618: ERROR/MainProcess] &lt;unknown&gt;:1:0: syntax error
  [2012-11-13 11:45:39,619: INFO/MainProcess] Task common_lib.send_notification[4dc71dee-fc7c-4ddc-a02c-4097c73e4384] succeeded in 11.5491399765s: None
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>when I changed the setting to </p>
  
  <pre><code>AWS_SES_REGION_ENDPOINT = 'email.us-east-1.amazonaws.com'
  </code></pre>
  
  <p>I got a different error, as below </p>
  
  <pre><code>[2012-11-13 13:24:05,907: DEBUG/MainProcess] Method: POST
  [2012-11-13 13:24:05,916: DEBUG/MainProcess] Path: /
  [2012-11-13 13:24:05,917: DEBUG/MainProcess] Data: Action=GetSendQuota
  [2012-11-13 13:24:05,917: DEBUG/MainProcess] Headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
  [2012-11-13 13:24:05,918: DEBUG/MainProcess] Host: email.us-east-1.amazonaws.com
  [2012-11-13 13:24:05,918: DEBUG/MainProcess] establishing HTTPS connection: host=email.us-east-1.amazonaws.com, kwargs={}
  [2012-11-13 13:24:05,919: DEBUG/MainProcess] Token: None
  [2012-11-13 13:24:06,511: DEBUG/MainProcess] wrapping ssl socket; CA certificate file=/home/mo/projects/garageenv/local/lib/python2.7/site-packages/boto/cacerts/cacerts.txt
  [2012-11-13 13:24:06,952: DEBUG/MainProcess] validating server certificate: hostname=email.us-east-1.amazonaws.com, certificate hosts=['email.us-east-1.amazonaws.com', 'email.amazonaws.com']
  [2012-11-13 13:24:07,177: ERROR/MainProcess] 403 Forbidden
  [2012-11-13 13:24:07,178: ERROR/MainProcess] &lt;ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/"&gt;
    &lt;Error&gt;
      &lt;Type&gt;Sender&lt;/Type&gt;
      &lt;Code&gt;SignatureDoesNotMatch&lt;/Code&gt;
      &lt;Message&gt;The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.&lt;/Message&gt;
    &lt;/Error&gt;
    &lt;RequestId&gt;41c15592-2d7c-11e2-a590-f33d1568f3ea&lt;/RequestId&gt;
  &lt;/ErrorResponse&gt;
  
  [2012-11-13 13:24:07,180: ERROR/MainProcess] BotoServerError: 403 Forbidden
  &lt;ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/"&gt;
    &lt;Error&gt;
      &lt;Type&gt;Sender&lt;/Type&gt;
      &lt;Code&gt;SignatureDoesNotMatch&lt;/Code&gt;
      &lt;Message&gt;The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.&lt;/Message&gt;
    &lt;/Error&gt;
    &lt;RequestId&gt;41c15592-2d7c-11e2-a590-f33d1568f3ea&lt;/RequestId&gt;
  &lt;/ErrorResponse&gt;
  
  [2012-11-13 13:24:07,184: INFO/MainProcess] Task common_lib.send_notification[3b6a049e-d5cb-45f4-842b-633d816a132e] succeeded in 1.31089687347s: None
  </code></pre>