✉️ 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 on the API Keys page in 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.email.send({
type: 'welcome_email',
to: 'user@example.com',
subject: 'Welcome to Acme Corp',
html: '<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>',
fromName: 'Acme Team',
fromAddress: 'hello@acme.com'
});
import asyncio
from pingram import Pingram
from pingram.models import SendEmailRequest
async def send_email():
async with Pingram(api_key="pingram_sk_...") as client:
await client.email.email_send(
SendEmailRequest(
type="welcome_email",
to="user@example.com",
subject="Welcome to Acme Corp",
html="<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>",
from_name="Acme Team",
from_address="hello@acme.com",
)
)
# Run the async function
asyncio.run(send_email())
use Pingram\Client;
use Pingram\Model\SendEmailRequest;
$client = new Client('pingram_sk_...');
$body = new SendEmailRequest([
'type' => 'welcome_email',
'to' => 'user@example.com',
'subject' => 'Welcome to Acme Corp',
'html' => '<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>',
'fromName' => 'Acme Team',
'fromAddress' => 'hello@acme.com',
]);
$client->getEmail()->emailSend($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.NewSendEmailRequest(
"welcome_email",
"user@example.com",
"Welcome to Acme Corp",
"<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>",
)
body.FromName = pingram.PtrString("Acme Team")
body.FromAddress = pingram.PtrString("hello@acme.com")
_, _, err := client.EmailAPI.EmailSend(context.Background()).SendEmailRequest(*body).Execute()
if err != nil {
log.Fatal(err)
}
}
using Pingram;
using Pingram.Model;
var client = new PingramClient("pingram_sk_...");
var body = new SendEmailRequest(
type: "welcome_email",
to: "user@example.com",
subject: "Welcome to Acme Corp",
html: "<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>"
)
{
FromName = "Acme Team",
FromAddress = "hello@acme.com"
};
await client.EmailApi.EmailSendAsync(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
SendEmailRequest body = new SendEmailRequest()
.type("welcome_email")
.to("user@example.com")
.subject("Welcome to Acme Corp")
.html("<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>")
.fromName("Acme Team")
.fromAddress("hello@acme.com");
SendEmailApiResponse response = pingram.getEmail().emailSend(body);
System.out.println("Tracking ID: " + response.getTrackingId());
}
}
require 'pingram'
client = Pingram::Client.new(api_key: 'pingram_sk_...')
body = Pingram::SendEmailRequest.new(
type: 'welcome_email',
to: 'user@example.com',
subject: 'Welcome to Acme Corp',
html: '<h1>Welcome!</h1><p>Thanks for joining Acme Corp.</p>',
from_name: 'Acme Team',
from_address: 'hello@acme.com'
)
client.email.email_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 documentation.