Reference

SDKs and Libraries

Official PostMTA SDKs are available for six languages. All are open-source, fully typed, and maintained with feature parity to the REST API.

Node.js / TypeScript

npm install @postmta/sdk
import { PostMTA } from '@postmta/sdk';
const client = new PostMTA({ apiKey: process.env.POSTMTA_API_KEY });
const message = await client.messages.send({from:{address:'hello@example.com'},to:[{address:'alice@example.com'}],subject:'Hello from PostMTA',html:'

Hi Alice!

'}); console.log(message.id);

Python

pip install postmta-python
from postmta import PostMTA
client = PostMTA(api_key="pmta_live_xxxx")
message = client.messages.send(from_addr="hello@example.com",to_addrs=["alice@example.com"],subject="Hello from PostMTA",html="

Hi Alice!

") print(message.id)

Go

go get github.com/postmta/postmta-go
package main
import ("github.com/postmta/postmta-go";"context")
func main() {
  client := postmta.NewClient("pmta_live_xxxx")
  msg, _ := client.Messages.Send(context.Background(), &postmta.SendMessageInput{From:&postmta.Address{Address:"hello@example.com"},To:[]*postmta.Address{{Address:"alice@example.com"}},Subject:"Hello from PostMTA",HTML:"

Hi Alice!

"}) fmt.Println(msg.ID) }

Ruby

require 'postmta'
client = PostMTA::Client.new(api_key: ENV['POSTMTA_API_KEY'])
message = client.messages.send(from:{address:'hello@example.com'},to:[{address:'alice@example.com'}],subject:'Hello',html:'

Hi!

') puts message.id

PHP

composer require postmta/php
$client = new \PostMTA\Client(['api_key' => 'pmta_live_xxxx']);
$message = $client->messages->send(['from' => ['address' => 'hello@example.com'], 'to' => [['address' => 'alice@example.com']], 'subject' => 'Hello', 'html' => '

Hi!

']); echo $message->id;

Java


  com.postmta
  postmta-java
  2.4.0

Community Libraries