Giter Site home page Giter Site logo

pmtaemailapi's Introduction

PowerMTA Email API

Submit emails to PowerMTA with HTTP and JSON instead of SMTP and MIME.

The Email API is used to submit email messages for delivery. You specify address headers, subject, text, and html. The Email API assembles the email, encodes it according to the appropriate standards, and submits it to PowerMTA.

Getting started

Start on PowerMTA server with:

pmtaemailapi -listen 127.0.0.1:8000 -pickup /var/pickup

Submit email messages by posting JSON to http://127.0.0.1:8000/messages.

curl http://127.0.0.1:8000/messages -d '{"from":"[email protected]","to":"[email protected]","subject":"Test","text":"This is a test"}'

API reference

The JSON message object can contain the following name/value pairs:

Name Type Description
sender string Envelope sender address
from object/string Address to use in from header
to array/object/string Address(es) to use in to header
cc array/object/string Address(es) to use in cc header
bcc array/object/string Address(es) to use as bcc
subject string Subject line
text string Content for text part
html string Content for html part

An address can be specified as object or as string. An address object contains the following name/value pairs:

Name Type Description
name string Display name
address string Email address

All strings are expected to be encoded as UTF-8. Display names are MIME word-encoded if needed. Text and HTML bodies are transfer-encoded with quoted-printable.

There is no access control. Make sure that the API is listening on private IPs or use a firewall.

Example code

Python

Install requests library with easy_install requests.

import json
import requests

url = "http://localhost:8000/messages"
headers = {'content-type': 'application/json'}
payload = {
        'from': 'Jim <[email protected]>', 
        'to': '[email protected]',
        'subject': 'test',
        'text': 'This is a test'}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print r.status_code
print r.text

pmtaemailapi's People

Contributors

maarten-postmastery avatar

Stargazers

Mailergeek avatar  Ibrahim Sharif avatar Omar Abdennour avatar  avatar  avatar  avatar Suke Han avatar  avatar Simon Luger avatar Fabio M avatar  avatar Avinash Kulkarni avatar  avatar Aravind Avvaru avatar vasanth.N avatar Solvik avatar

Watchers

 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.