1. MailChimp
  2. Untitled project
  3. mandrill-api-python


MailChimp  committed 6d3353b

Add the from_email, from_name, and to parameters to messages/send-raw to override the data provided in the raw SMTP document

  • Participants
  • Parent commits 746acec
  • Branches master
  • Tags 1.0.2

Comments (0)

Files changed (2)

File mandrill.py

View file
  • Ignore whitespace
         params = json.dumps(params)
         self.log('POST to %s%s.json: %s' % (ROOT, url, params))
         start = time.time()
-        r = self.session.post('%s%s.json' % (ROOT, url), data=params, headers={'content-type': 'application/json', 'user-agent': 'Mandrill-Python/1.0'})
+        r = self.session.post('%s%s.json' % (ROOT, url), data=params, headers={'content-type': 'application/json', 'user-agent': 'Mandrill-Python/1.0.2'})
             remote_addr = r.raw._original_response.fp._sock.getpeername() # grab the remote_addr before grabbing the text since the socket will go away
         _params = {'raw_message': raw_message}
         return self.master.call('messages/parse', _params)
-    def send_raw(self, raw_message):
+    def send_raw(self, raw_message, from_email=None, from_name=None, to=None):
         """Take a raw MIME document for a message, and send it exactly as if it were sent over the SMTP protocol
            raw_message (string): the full MIME document of an email message
+           from_email (string|null): optionally define the sender address - otherwise we'll use the address found in the provided headers
+           from_name (string|null): optionally define the sender alias
+           to (array|null): optionally define the recipients to receive the message - otherwise we'll use the To, Cc, and Bcc headers provided in the document::
+               to[] (string): the email address of the recipint
            array.  of structs for each recipient containing the key "email" with the email address and "status" as either "sent", "queued", or "rejected"::
                [] (struct): the sending results for a single recipient::
                    [].email (string): the email address of the recipient
-                   [].status (string): the sending status of the recipient - either "sent", "queued", or "rejected"
+                   [].status (string): the sending status of the recipient - either "sent", "queued", "rejected", or "invalid"
            InvalidKeyError: The provided API key is not a valid Mandrill API key
            Error: A general Mandrill error has occurred
-        _params = {'raw_message': raw_message}
+        _params = {'raw_message': raw_message, 'from_email': from_email, 'from_name': from_name, 'to': to}
         return self.master.call('messages/send-raw', _params)

File setup.py

View file
  • Ignore whitespace
     name = 'mandrill',
-    version = '1.0.1',
+    version = '1.0.2',
     author = 'Mandrill Devs',
     author_email = 'community@mandrill.com',
     description = 'A CLI client and Python API library for the Mandrill email as a service platform.',