Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

sendwithus is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
1.0.4 Failed View build log
 
Links
Author
License
LICENSE.txt
Dependencies
Lastest release
version 1.0.4 on Jan 9th, 2014

## status BETA - this client implements v1_0 of SWU API and is functional and tested

[![Build Status](https://travis-ci.org/sendwithus/sendwithus_python.png)](https://travis-ci.org/sendwithus/sendwithus_python)

## requirements python requests library

## installation
pip install sendwithus
## to run tests
python setup.py test

## usage

For all examples, assume: `python import sendwithus api = sendwithus.api(api_key='YOUR-API-KEY') `

### Call with REQUIRED parameters only The email_data field is optional, but highly recommended!

```python r = api.send(

System Message: WARNING/2 (<string>, line 29); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 29); backlink

Inline interpreted text or phrase reference start-string without end-string.

System Message: ERROR/3 (<string>, line 31)

Unexpected indentation.
email_id='YOUR-EMAIL-ID', recipient={'address': 'us@sendwithus.com'})

System Message: WARNING/2 (<string>, line 33)

Block quote ends without a blank line; unexpected unindent.

print r.status_code # 200 ```

System Message: WARNING/2 (<string>, line 33); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 33); backlink

Inline interpreted text or phrase reference start-string without end-string.

### Call with REQUIRED parameters and email_data ```python r = api.send(

System Message: WARNING/2 (<string>, line 37); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 37); backlink

Inline interpreted text or phrase reference start-string without end-string.

System Message: ERROR/3 (<string>, line 40)

Unexpected indentation.
email_id='YOUR-EMAIL-ID', recipient={'address': 'us@sendwithus.com'}, email_data={ 'first_name': 'Matt' })

System Message: WARNING/2 (<string>, line 43)

Block quote ends without a blank line; unexpected unindent.

print r.status_code # 200 ```

System Message: WARNING/2 (<string>, line 43); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 43); backlink

Inline interpreted text or phrase reference start-string without end-string.

### Optional Sender The sender['address'] is a required sender field

```python r = api.send(

System Message: WARNING/2 (<string>, line 50); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 50); backlink

Inline interpreted text or phrase reference start-string without end-string.

System Message: ERROR/3 (<string>, line 52)

Unexpected indentation.

email_id='YOUR-EMAIL-ID', recipient={ 'name': 'Matt',

System Message: ERROR/3 (<string>, line 54)

Unexpected indentation.
'address': 'us@sendwithus.com'},

System Message: WARNING/2 (<string>, line 55)

Block quote ends without a blank line; unexpected unindent.

email_data={ 'first_name': 'Matt' }, sender={ 'address':'company@company.com' })

System Message: WARNING/2 (<string>, line 57)

Block quote ends without a blank line; unexpected unindent.

print r.status_code # 200 ```

System Message: WARNING/2 (<string>, line 57); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 57); backlink

Inline interpreted text or phrase reference start-string without end-string.

### Optional Sender with reply_to address sender['name'] and sender['reply_to'] are both optional

```python r = api.send(

System Message: WARNING/2 (<string>, line 64); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 64); backlink

Inline interpreted text or phrase reference start-string without end-string.

System Message: ERROR/3 (<string>, line 66)

Unexpected indentation.

email_id='YOUR-EMAIL-ID', recipient={ 'name': 'Matt',

System Message: ERROR/3 (<string>, line 68)

Unexpected indentation.
'address': 'us@sendwithus.com'},

System Message: WARNING/2 (<string>, line 69)

Block quote ends without a blank line; unexpected unindent.

email_data={ 'first_name': 'Matt' }, sender={ 'name': 'Company',

System Message: ERROR/3 (<string>, line 71)

Unexpected indentation.
'address':'company@company.com', 'reply_to':'info@company.com'})

System Message: WARNING/2 (<string>, line 73)

Block quote ends without a blank line; unexpected unindent.

print r.status_code # 200 ```

System Message: WARNING/2 (<string>, line 73); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 73); backlink

Inline interpreted text or phrase reference start-string without end-string.

## expected response

### Success
>>> r.status_code
200
>>> r.json().get('success')
True
>>> r.json().get('status')
u'OK'
>>> r.json().get('receipt_id')
u'numeric-receipt-id'

### Error cases * malformed request

>>> r.status_code
400
  • bad api key

    >>> r.status_code
    

    System Message: WARNING/2 (<string>, line 101)

    Block quote ends without a blank line; unexpected unindent.

    403

  • email_id not found

    >>> r.status_code
    404
    
### packaging (internal)
python setup.py sdist upload

Subscribe to package updates

Last updated Jan 9th, 2014

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.