Scripts d'exemple avec Mailjet et Python.

Description

Mailjet's Python library will help you access our REST API. Please note that this is not an official library, but an original contribution of Rick van Hattem.

Files and documentation are available on github: Mailjet's Python library

Install

To install simply execute python setup.py install.

The settings can be configured from a Django settings file through MAILJET_API_KEY and MAILJET_SECRET_KEY. Or through environment variables the same name.

i.e.

 
export MAILJET_API_KEY=something
export MAILJET_SECRET_KEY=something_else
 

Usage

To fetch data:

 
>>> import mailjet
>>> print mailjet.Api.user.infos()
{
    u'status': u'OK',
    u'infos': {
        u'username': u'user@domain.com',
        u'firstname': u'firstname',
        u'locale': u'en_US',
        u'lastname': u'lastname',
        u'company_name': u'company_name',
        u'contact_phone': None,
    },
}
 

To put data:

 
>>> list_ = api.lists.create(label='Test', name='test')
>>> print list_
{u'status': u'OK', u'list_id': ...}
>>> print api.user.addcontact(
    contact='user@domain.com',
    id=list_['list_id'],
)
 

More

Ressources:
- The package: http://pypi.python.org/pypi/mailjet/
- Documentation: http://packages.python.org/mailjet/
- Source: https://github.com/WoLpH/mailjet