MailChimp avatar 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

Comments (0)

Files changed (2)

         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'})
         try:
             remote_addr = r.raw._original_response.fp._sock.getpeername() # grab the remote_addr before grabbing the text since the socket will go away
         except:
         _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
 
         Args:
            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
 
         Returns:
            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"
 
 
         Raises:
            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)
 
 
 
 setup(
     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.',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.