GithubHelp home page GithubHelp logo

jpadilla / mandrill-inbound-python Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 7.0 281 KB

Python Wrapper for Mandrill Inbound Email

Home Page: http://jpadilla.github.io/mandrill-inbound-python

License: MIT License

Python 100.00%
python mandrill

mandrill-inbound-python's Introduction

Mandrill Inbound Python Wrapper Build Status

This is a simple API wrapper for Mandrill's inbound email webhook in Python inspired by this other Python wrapper library I made for Postmark Inbound.

Install

Using Github:

git clone git://github.com/jpadilla/mandrill-inbound-python.git

Using pip:

pip install python-mandrill-inbound

Using easy_install:

easy_install python-mandrill-inbound

Usage

from mandrill_inbound import MandrillInbound


# Load from JSON string
json_data = open('./tests/fixtures/valid_http_post.json').read()
inbound = MandrillInbound(json=json_data)

# Load Python dictionary
json_data = json.loads(open('./tests/fixtures/valid_http_post.json').read())
inbound = MandrillInbound(source=json_data)

# Content
print inbound.subject
print inbound.sender
print inbound.to
print inbound.cc
print inbound.recipients
print inbound.message_id
print inbound.mailbox_hash
print inbound.html_body
print inbound.text_body
print inbound.send_date
print inbound.ts

# Spam and Spoofing Detection
print inbound.spf
print inbound.dkim
print inbound.spam_score

# headers
print inbound.headers  # default to get all headers
print inbound.headers['MIME-Version']
print inbound.headers['Received-SPF']

# attachments
print inbound.has_attachments # boolean
attachments = inbound.attachments

first_attachment = attachments[0]
print first_attachment.name

second_attachment = attachments[1]
print second_attachment.content_length

for a in attachments:
	print a.name
	print a.content_type
	print a.read()
	print a.download('./tests/', ['image/png'])

# raw data
print inbound.source
print inbound.msg

Bug tracker

Have a bug? Please create an issue here on GitHub!

Contributions

  • Fork
  • Write tests
  • Write Code
  • Pull request

Thanks for your help.

License

MIT License

mandrill-inbound-python's People

Contributors

bootandy avatar garetjax avatar jpadilla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mandrill-inbound-python's Issues

Error when installing v0.0.2 via PIP

Error when installing v0.0.2 via PIP:

I assume this is an error with the manifest.in file not including the README. But I can not see the manifest file on github.

Error:

Downloading/unpacking python-mandrill-inbound
Downloading python-mandrill-inbound-0.0.2.tar.gz
Running setup.py egg_info for package python-mandrill-inbound
Traceback (most recent call last):
File "", line 16, in
File "/.../.virtualenvs/hack/build/python-mandrill-inbound/setup.py", line 15, in
long_description = open(readme_md).read()
IOError: [Errno 2] No such file or directory: '/.../.virtualenvs/hack/build/python-mandrill-inbound/README.md'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 16, in

File ".../.virtualenvs/hack/build/python-mandrill-inbound/setup.py", line 15, in

long_description = open(readme_md).read()

IOError: [Errno 2] No such file or directory: ..../.virtualenvs/hack/build/python-mandrill-inbound/README.md'

Question on inbound messages

Mandrill sends an array of objects, I'm wondering if there are cases where you get multiple messages per event?

It looks like the code assumes the first item in the returned array: https://github.com/jpadilla/mandrill-inbound-python/blob/master/mandrill_inbound/__init__.py#L18

Would it be accurate to change the example from:

json_data = json.loads(open('./tests/fixtures/valid_http_post.json').read())
inbound = MandrillInbound(source=json_data)

to

json_data = json.loads(open('./tests/fixtures/valid_http_post.json').read())
inbound = MandrillInbound(source=json_data[0])

?

Thanks, great helper library!

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.