βœ‰οΈ Send Emails

Pingram makes it easy to send emails without third parties like Twilio. Here’s how.

Install the SDK:

npm install pingram
pip install pingram-python
composer require pingram/php
go get github.com/pingram-io/pingram-go
dotnet add package Pingram

Add the Pingram dependency to your pom.xml. Check Maven Central for the latest version.

<dependencies>
    <dependency>
        <groupId>io.pingram</groupId>
        <artifactId>pingram</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>
gem install pingram

Or add to your Gemfile: gem 'pingram'

Now, send an email notification from your backend:

TIP

Use your API key (pingram_sk_...). You can find it in the Environments section of the Pingram dashboard.

import { Pingram } from 'pingram';

// Initialize with API key
const pingram = new Pingram({
  apiKey: 'pingram_sk_...' // Your secret API key
});

// Send email notification
await pingram.send({
  type: 'welcome_email',
  to: {
    email: 'user@example.com' // Required for email notifications
  },
  email: {
    subject: 'Welcome to Acme Corp',
    html: '<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>',
    senderName: 'Acme Team',
    senderEmail: 'hello@acme.com'
  }
});
import asyncio
from pingram import Pingram

async def send_email():
    async with Pingram(api_key="pingram_sk_...") as client:
        await client.send({
            "type": "welcome_email",
            "to": {
                "email": "user@example.com"  # Required for email notifications
            },
            "email": {
                "subject": "Welcome to Acme Corp",
                "html": "<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>",
                "senderName": "Acme Team",
                "senderEmail": "hello@acme.com"
            }
        })

# Run the async function
asyncio.run(send_email())
use Pingram\Client;
use Pingram\Model\SenderPostBody;

$client = new Client('pingram_sk_...');

$body = new SenderPostBody([
    'type' => 'welcome_email',
    'to' => [
        'id' => 'user123',
        'email' => 'user@example.com'  // Required for email notifications
    ],
    'email' => [
        'subject' => 'Welcome to Acme Corp',
        'html' => '<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>',
        'senderName' => 'Acme Team',
        'senderEmail' => 'hello@acme.com'
    ]
]);
$client->send($body);
package main

import (
    "context"
    "log"

    pingram "github.com/pingram-io/pingram-go"
)

func main() {
    client := pingram.NewClient("pingram_sk_...") // Your secret API key

    body := pingram.SenderPostBody{
        Type: pingram.PtrString("welcome_email"),
        User: &pingram.GetUsersResponseUsersInner{
            Id:    "user123",
            Email: pingram.PtrString("user@example.com"), // Required for email notifications
        },
        Email: &pingram.SenderPostBodyEmail{
            Subject:     "Welcome to Acme Corp",
            Html:        "<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>",
            SenderName:  pingram.PtrString("Acme Team"),
            SenderEmail: pingram.PtrString("hello@acme.com"),
        },
    }

    _, _, err := client.DefaultAPI.Send(context.Background()).SenderPostBody(body).Execute()
    if err != nil {
        log.Fatal(err)
    }
}
using Pingram;
using Pingram.Model;

var client = new PingramClient("your_api_key");
var body = new SenderPostBody
{
    Type = "welcome_email",
    To = new SenderPostBodyTo { Id = "user123", Email = "user@example.com" },
    Email = new SenderPostBodyEmail("Welcome to Acme Corp", "<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>")
    {
        SenderName = "Acme Team",
        SenderEmail = "hello@acme.com"
    }
};
await client.SendAsync(body);
package com.example;

import io.pingram.Pingram;
import io.pingram.model.*;

public class Example {
    public static void main(String[] args) {
        Pingram pingram = new Pingram("pingram_sk_..."); // Your secret API key

        SenderPostBodyTo to = new SenderPostBodyTo()
            .id("user123")
            .email("user@example.com");

        SenderPostBody body = new SenderPostBody()
            .type("welcome_email")
            .to(to)
            .email(new SenderPostBodyEmail()
                .subject("Welcome to Acme Corp")
                .html("<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>")
                .senderName("Acme Team")
                .senderEmail("hello@acme.com")
            );

        SenderPostResponse response = pingram.send(body);
        System.out.println("Tracking ID: " + response.getTrackingId());
    }
}
require 'pingram'

client = Pingram::Client.new(api_key: 'pingram_sk_...')
body = Pingram::SenderPostBody.new(
  type: 'welcome_email',
  to: { id: 'user123', email: 'user@example.com' },
  email: { subject: 'Welcome to Acme Corp', html: '<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>' }
)
client.send(body)

You’re All Set!

πŸŽ‰ Congrats! You’re now sending email notifications!

For more advanced features like attachments, CC/BCC, and custom templates, check out our Email Channel documentation.