Git Product home page Git Product logo

ses.py's Introduction

ses.py: Amazon Simple Email Service API client

SES API version: 2010-12-01

Python Usage

Initialization:

>>> from ses improt SES, SESError
>>> ses = SES(key_id='YOUR ACCESS KEY ID', key='YOUR SECRET KEY')

Get sending quota:

>>> ses.quota
{'Max24HourSend': 1000, 'SentLast24Hours': 0, 'MaxSendRate': 1}

Get sending statistics:

>>> ses.stats
[{'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 2, 43), 'DeliveryAttempts': 2, 'Bounces': 1, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 2, 58), 'DeliveryAttempts': 1, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 3, 43), 'DeliveryAttempts': 9, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 3, 58), 'DeliveryAttempts': 6, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 4, 28), 'DeliveryAttempts': 2, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 5, 28), 'DeliveryAttempts': 2, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 7, 43), 'DeliveryAttempts': 1, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 8, 28), 'DeliveryAttempts': 3, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 13, 8, 58), 'DeliveryAttempts': 2, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 14, 2, 13), 'DeliveryAttempts': 6, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 14, 2, 28), 'DeliveryAttempts': 1, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 14, 2, 43), 'DeliveryAttempts': 6, 'Bounces': 0, 'Rejects': 0},
 {'Complaints': 0, 'Timestamp': datetime.datetime(2011, 8, 14, 3, 28), 'DeliveryAttempts': 1, 'Bounces': 0, 'Rejects': 0}]

timestamp is seconds since UNIX epoch in GMT/UTC. Every point represents the sending statistics during a 15-minute interval.

Get verified email addresses:

>>> ses.verified
[u'[email protected]', u'[email protected]']

Verify an email address:

>>> ses.verify('[email protected]')
{'RequestId': u'0f7297f3-c764-11e0-b6d0-273d09173b49'}

Delete a verified email address:

>>> ses.delete('[email protected]')
{'RequestId': u'36b0fb55-c764-11e0-ac10-2114a1a1f8e9'}

Send an email:

>>> ses.send(source    = '[email protected]',
...          to        = ['[email protected]', '[email protected]'],
...          subject   = 'This is a test message',
...          text_body = 'Message body in plain text',
...          html_body = 'Message body in HTML')
{'MessageId': u'00000131ce811456-6d32754c-8e68-4efc-9026-8c00518d901e-000000',
 'RequestId': u'a5aa67d0-c764-11e0-9f8f-3da8fc215a7e'}

Sending raw emails is not implemented yet.

All actions listed above will block while waiting for response from Amazon SES. All actions will raise SESError in case of error.

Command Line Usage

ses.py also provides command line interface, here is its help message:

ses.py [action] -k [credentials file] [args]

Example
-------
1. Sending email:

    echo "email text body" | ses.py send -k [credentials file] -f from_addr -t [to_addr1,to_addr2,...] -c [cc_addr1,cc_addr2,...] -b [bcc_addr1,bcc_addr2,...] -s "email subject" 


2. Get send quota:

    ses.py quota -k [credentials file]


3. Get send statistics:

    ses.py stats -k [credentials file]


4. Get verified email addresses:

    ses.py verified -k [credentials file]


5. Verify email addreses:

    ses.py verify -k [credentials file] [addr1,addr2,...]


6. Delete verified email addresses:

    ses.py delete -k [credentials file] [addr1,addr2,...]


Credentials file example
------------------------

    AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX
    AWSSecretKey=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

ses.py's People

Contributors

riobard avatar

Watchers

Bach Quang Bao Toan avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.