- Associate the email a “customer ID” from your application
- Add a label from your database like “free” or “enterprise”
- Note the category of email sent, like “welcome” or “password reset”
Add tags on the POST /emails endpoint
import { Emailr } from 'emailr';
const emailr = new Emailr('em_xxxxxxxxx');
await emailr.emails.send({
from: 'Acme <[email protected]>',
to: ['[email protected]'],
subject: 'hello world',
html: '<p>it works!</p>',
tags: [
{
name: 'category',
value: 'confirm_email',
},
],
});
$emailr = Emailr::client('em_xxxxxxxxx');
$emailr->emails->send([
'from' => 'Acme <[email protected]>',
'to' => ['[email protected]'],
'subject' => 'hello world',
'html' => '<p>it works!</p>',
'tags' => [
[
'name' => 'category',
'value' => 'confirm_email',
],
]
]);
import emailr
emailr.api_key = "em_xxxxxxxxx"
params: emailr.Emails.SendParams = {
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"tags": [
{"name": "category", "value": "confirm_email"},
],
}
email = emailr.Emails.send(params)
print(email)
require "emailr"
Emailr.api_key = "em_xxxxxxxxx"
params = {
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"tags": [
{"name": "category", "value": "confirm_email"}
]
}
sent = Emailr::Emails.send(params)
puts sent
import (
"fmt"
"github.com/emailr/emailr-go/v3"
)
func main() {
ctx := context.TODO()
client := emailr.NewClient("em_xxxxxxxxx")
params := &emailr.SendEmailRequest{
From: "Acme <[email protected]>",
To: []string{"[email protected]"},
Text: "<p>it works!</p>",
Subject: "hello world",
Tags: []emailr.Tag{{Name: "category", Value: "confirm_email"}},
}
sent, err := client.Emails.SendWithContext(ctx, params)
if err != nil {
panic(err)
}
fmt.Println(sent.Id)
}
use emailr_rs::types::{CreateEmailBaseOptions, Tag};
use emailr_rs::{Emailr, Result};
#[tokio::main]
async fn main() -> Result<()> {
let emailr = Emailr::new("em_xxxxxxxxx");
let from = "Acme <[email protected]>";
let to = ["[email protected]"];
let subject = "hello world";
let email = CreateEmailBaseOptions::new(from, to, subject)
.with_html("<p>it works!</p>")
.with_tag(Tag::new("category", "confirm_email"));
let _email = emailr.emails.send(email).await?;
Ok(())
}
import com.emailr.*;
public class Main {
public static void main(String[] args) {
Emailr emailr = new Emailr("em_xxxxxxxxx");
Tag tag = Tag.builder()
.name("category")
.value("confirm_email")
.build();
SendEmailRequest sendEmailRequest = SendEmailRequest.builder()
.from("Acme <[email protected]>")
.to("[email protected]")
.subject("hello world")
.html("<p>it works!</p>")
.tags(tag)
.build();
SendEmailResponse data = emailr.emails().send(sendEmailRequest);
}
}
using Emailr;
IEmailr emailr = EmailrClient.Create( "em_xxxxxxxxx" ); // Or from DI
var resp = await emailr.EmailSendAsync( new EmailMessage()
{
From = "Acme <[email protected]>",
To = "[email protected]",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
ReplyTo = "[email protected]",
Tags = new List<EmailTag> { new EmailTag { Name = "category", Value = "confirm_email" } }
} );
Console.WriteLine( "Email Id={0}", resp.Content );
curl -X POST 'https://api.emailr.dev/emails' \
-H 'Authorization: Bearer em_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d $'{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"tags": [
{
"name": "category",
"value": "confirm_email"
}
]
}'
Add tags on the POST /emails/batch endpoint
import { Emailr } from 'emailr';
const emailr = new Emailr('em_xxxxxxxxx');
const { data, error } = await emailr.batch.send([
{
from: 'Acme <[email protected]>',
to: ['[email protected]'],
subject: 'hello world',
html: '<h1>it works!</h1>',
tags: [
{
name: 'category',
value: 'confirm_email',
},
],
},
{
from: 'Acme <[email protected]>',
to: ['[email protected]'],
subject: 'world hello',
html: '<p>it works!</p>',
tags: [
{
name: 'category',
value: 'confirm_email',
},
],
},
]);
$emailr = Emailr::client('em_xxxxxxxxx');
$emailr->batch->send([
[
'from' => 'Acme <[email protected]>',
'to' => ['[email protected]'],
'subject' => 'hello world',
'html' => '<h1>it works!</h1>',
'tags' => [
[
'name' => 'category',
'value' => 'confirm_email'
]
]
],
[
'from' => 'Acme <[email protected]>',
'to' => ['[email protected]'],
'subject' => 'world hello',
'html' => '<p>it works!</p>',
'tags' => [
[
'name' => 'category',
'value' => 'confirm_email'
]
]
]
]);
import emailr
from typing import List
emailr.api_key = "em_xxxxxxxxx"
params: List[emailr.Emails.SendParams] = [
{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<h1>it works!</h1>",
"tags": [
{
"name": "category",
"value": "confirm_email"
}
]
},
{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "world hello",
"html": "<p>it works!</p>",
"tags": [
{
"name": "category",
"value": "confirm_email"
}
]
}
]
emailr.Batch.send(params)
require "emailr"
Emailr.api_key = 'em_xxxxxxxxx'
params = [
{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<h1>it works!</h1>",
"tags": [
{
"name": "category",
"value": "confirm_email"
}
]
},
{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "world hello",
"html": "<p>it works!</p>",
"tags": [
{
"name": "category",
"value": "confirm_email"
}
]
}
]
Emailr::Batch.send(params)
package examples
import (
"fmt"
"os"
"github.com/emailr/emailr-go/v3"
)
func main() {
ctx := context.TODO()
client := emailr.NewClient("em_xxxxxxxxx")
var batchEmails = []*emailr.SendEmailRequest{
{
From: "Acme <[email protected]>",
To: []string{"[email protected]"},
Subject: "hello world",
Html: "<h1>it works!</h1>",
Tags: []emailr.Tag{{Name: "category", Value: "confirm_email"}},
},
{
From: "Acme <[email protected]>",
To: []string{"[email protected]"},
Subject: "world hello",
Html: "<p>it works!</p>",
Tags: []emailr.Tag{{Name: "category", Value: "confirm_email"}},
},
}
sent, err := client.Batch.SendWithContext(ctx, batchEmails)
if err != nil {
panic(err)
}
fmt.Println(sent.Data)
}
use emailr_rs::types::CreateEmailBaseOptions;
use emailr_rs::{Emailr, Result};
#[tokio::main]
async fn main() -> Result<()> {
let emailr = Emailr::new("em_xxxxxxxxx");
let emails = vec![
CreateEmailBaseOptions::new(
"Acme <[email protected]>",
vec!["[email protected]"],
"hello world",
)
.with_html("<h1>it works!</h1>")
.with_tag(Tag::new("category", "confirm_email")),
CreateEmailBaseOptions::new(
"Acme <[email protected]>",
vec!["[email protected]"],
"world hello",
)
.with_html("<p>it works!</p>")
.with_tag(Tag::new("category", "confirm_email")),
];
let _emails = emailr.batch.send(emails).await?;
Ok(())
}
import com.emailr.*;
public class Main {
public static void main(String[] args) {
Emailr emailr = new Emailr("em_xxxxxxxxx");
CreateEmailOptions firstEmail = CreateEmailOptions.builder()
.from("Acme <[email protected]>")
.to("[email protected]")
.subject("hello world")
.html("<h1>it works!</h1>")
.tags(Tag.builder()
.name("category")
.value("confirm_email")
.build())
.build();
CreateEmailOptions secondEmail = CreateEmailOptions.builder()
.from("Acme <[email protected]>")
.to("[email protected]")
.subject("world hello")
.html("<p>it works!</p>")
.tags(Tag.builder()
.name("category")
.value("confirm_email")
.build())
.build();
CreateBatchEmailsResponse data = emailr.batch().send(
Arrays.asList(firstEmail, secondEmail)
);
}
}
using Emailr;
IEmailr emailr = EmailrClient.Create( "em_xxxxxxxxx" ); // Or from DI
var mail1 = new EmailMessage()
{
From = "Acme <[email protected]>",
To = "[email protected]",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
Tags = new List<EmailTag> { new EmailTag { Name = "category", Value = "confirm_email" } }
};
var mail2 = new EmailMessage()
{
From = "Acme <[email protected]>",
To = "[email protected]",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
Tags = new List<EmailTag> { new EmailTag { Name = "category", Value = "confirm_email" } }
};
var resp = await emailr.EmailBatchAsync( [ mail1, mail2 ] );
Console.WriteLine( "Nr Emails={0}", resp.Content.Count );
curl -X POST 'https://api.emailr.dev/emails/batch' \
-H 'Authorization: Bearer em_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d $'[
{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<h1>it works!</h1>",
"tags": [
{
"name": "category",
"value": "confirm_email"
}
]
},
{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "world hello",
"html": "<p>it works!</p>",
"tags": [
{
"name": "category",
"value": "confirm_email"
}
]
}
]'