跳转到主要内容

Mandrill Inbound的Python封装

项目描述

# Mandrill Inbound Python Wrapper [![Build Status](https://travis-ci.org/jpadilla/mandrill-inbound-python.png?branch=master)](https://travis-ci.org/jpadilla/mandrill-inbound-python)


这是一个简单的API封装,用于[Mandrill的入站邮件webhook](http://help.mandrill.com/entries/22092308-What-is-the-format-of-inbound-email-webhooks-)
在Python中受到我制作的这个Python封装库的启发,该库用于[Postmark Inbound](https://github.com/jpadilla/postmark-inbound-python)。

## 安装

使用Github

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

使用pip

```
pip安装python-mandrill-inbound
```

使用easy_install

```
easy_install python-mandrill-inbound
```


使用方法
-----

```python
from mandrill_inbound import MandrillInbound


# 从JSON字符串加载
json_data = open('./tests/fixtures/valid_http_post.json').read()
inbound = MandrillInbound(json=json_data)

# 从Python字典加载
json_data = json.loads(open('./tests/fixtures/valid_http_post.json').read())
inbound = MandrillInbound(source=json_data)

# 内容
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

# 垃圾邮件和欺骗检测
print inbound.spf
print inbound.dkim
print inbound.spam_score

# 头部
print inbound.headers # 默认获取所有头部信息
print inbound.headers['MIME-Version']
print inbound.headers['Received-SPF']

# 附件
print inbound.has_attachments # 布尔值
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'])

# 原始数据
print inbound.source
print inbound.msg
```

错误追踪器
-----------

有错误吗?请在此GitHub上创建一个问题!


贡献
-------------

* 分支
* 编写测试
* 编写代码
* 提交拉取请求

感谢您的帮助。


许可证
---------------------

MIT许可证

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

python-mandrill-inbound-0.0.4.tar.gz (4.7 kB 查看哈希值)

上传时间 源代码

支持者