Hello {{{FIRST_NAME|there}}}!
", "text": "Hello {{{FIRST_NAME|there}}}!", "status": "draft", "created_at": "2024-12-01T19:32:22.980Z", "scheduled_at": null, "sent_at": null, "topic_id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ```it works!
', }, ]); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->batch->send([ [ 'from' => 'Acmeit works!
', ] ]); ``` ```py Python theme={null} import resend from typing import List resend.api_key = "re_xxxxxxxxx" params: List[resend.Emails.SendParams] = [ { "from": "Acmeit works!
", } ] resend.Batch.send(params) ``` ```rb Ruby theme={null} require "resend" Resend.api_key = 're_xxxxxxxxx' params = [ { "from": "Acmeit works!
", } ] Resend::Batch.send(params) ``` ```go Go theme={null} package examples import ( "fmt" "os" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") var batchEmails = []*resend.SendEmailRequest{ { From: "Acmeit works!
", }, } sent, err := client.Batch.SendWithContext(ctx, batchEmails) if err != nil { panic(err) } fmt.Println(sent.Data) } ``` ```rust Rust theme={null} use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let emails = vec![ CreateEmailBaseOptions::new( "Acmeit works!
"), ]; let _emails = resend.batch.send(emails).await?; Ok(()) } ``` ```java Java theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions firstEmail = CreateEmailOptions.builder() .from("Acmeit works!
") .build(); CreateBatchEmailsResponse data = resend.batch().send( Arrays.asList(firstEmail, secondEmail) ); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var mail1 = new EmailMessage() { From = "Acmeit works!
", }; var mail2 = new EmailMessage() { From = "Acmeit works!
", }; var resp = await resend.EmailBatchAsync( [ mail1, mail2 ] ); Console.WriteLine( "Nr Emails={0}", resp.Content.Count ); ``` ```bash cURL theme={null} curl -X POST 'https://api.resend.com/emails/batch' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'[ { "from": "Acmeit works!
" } ]' ```it works!
', replyTo: 'onboarding@resend.dev', }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'Acmeit works!
', 'reply_to': 'onboarding@resend.dev' ]); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Emails.SendParams = { "from": "Acmeit works!
", "reply_to": "onboarding@resend.dev" } email = resend.Emails.send(params) print(email) ``` ```rb Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "from": "Acmeit works!
", "reply_to": "onboarding@resend.dev" } sent = Resend::Emails.send(params) puts sent ``` ```go Go theme={null} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.SendEmailRequest{ From: "Acmeit works!
", ReplyTo: "onboarding@resend.dev" } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust theme={null} use resend_rs::types::{CreateEmailBaseOptions}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "Acmeit works!
"; let reply_to = "onboarding@resend.dev"; let email = CreateEmailBaseOptions::new(from, to, subject) .with_html(html); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions params = CreateEmailOptions.builder() .from("Acmeit works!
") .replyTo("onboarding@resend.dev") .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailSendAsync( new EmailMessage() { From = "Acmeit works!
", ReplyTo = "onboarding@resend.dev", } ); Console.WriteLine( "Email Id={0}", resp.Content ); ``` ```bash cURL theme={null} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "from": "Acmeit works!
", "reply_to": "onboarding@resend.dev" }' ```Thanks for the payment
', attachments: [ { path: 'https://resend.com/static/sample/invoice.pdf', filename: 'invoice.pdf', }, ], }); ``` ```php PHP {10-11} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'AcmeThanks for the payment
', 'attachments' => [ [ 'path' => 'https://resend.com/static/sample/invoice.pdf', 'filename' => 'invoice.pdf' ] ] ]); ``` ```python Python {6-7} theme={null} import resend resend.api_key = "re_xxxxxxxxx" attachment: resend.RemoteAttachment = { "path": "https://resend.com/static/sample/invoice.pdf", "filename": "invoice.pdf", } params: resend.Emails.SendParams = { "from": "AcmeThanks for the payment
", "attachments": [attachment], } resend.Emails.send(params) ``` ```rb Ruby {12-13} theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "from": "AcmeThanks for the payment
", "attachments": [ { "path": "https://resend.com/static/sample/invoice.pdf", "filename": 'invoice.pdf', } ] } Resend::Emails.send(params) ``` ```go Go {12-13} theme={null} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") attachment := &resend.Attachment{ Path: "https://resend.com/static/sample/invoice.pdf", Filename: "invoice.pdf", } params := &resend.SendEmailRequest{ From: "AcmeThanks for the payment
", Attachments: []*resend.Attachment{attachment}, } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust {12-13} theme={null} use resend_rs::types::{Attachment, CreateEmailBaseOptions}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "AcmeThanks for the payment
") .with_attachment(Attachment::from_path(path).with_filename(filename)); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {8-9} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); Attachment att = Attachment.builder() .path("https://resend.com/static/sample/invoice.pdf") .fileName("invoice.pdf") .build(); CreateEmailOptions params = CreateEmailOptions.builder() .from("AcmeThanks for the payment
") .attachments(att) .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```csharp .NET {14-18} theme={null} using Resend; using System.Collections.Generic; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var message = new EmailMessage() { From = "AcmeThanks for the payment
", }; message.Attachments = new ListThanks for the payment
", "attachments": [ { "path": "https://resend.com/static/sample/invoice.pdf", "filename": "invoice.pdf" } ] }' ```Thanks for the payment
', attachments: [ { content: attachment, filename: 'invoice.pdf', }, ], }); ``` ```php PHP {10-11} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'AcmeThanks for the payment
', 'attachments' => [ [ 'filename' => 'invoice.pdf', 'content' => $invoiceBuffer ] ] ]); ``` ```python Python {10} theme={null} import os import resend resend.api_key = "re_xxxxxxxxx" f: bytes = open( os.path.join(os.path.dirname(__file__), "../static/invoice.pdf"), "rb" ).read() attachment: resend.Attachment = {"content": list(f), "filename": "invoice.pdf"} params: resend.Emails.SendParams = { "from": "AcmeThanks for the payment
", "attachments": [attachment], } resend.Emails.send(params) ``` ```rb Ruby {14-15} theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" file = IO.read("invoice.pdf") params = { "from": "AcmeThanks for the payment
", "attachments": [ { "content": file.bytes, "filename": 'invoice.pdf', } ] } Resend::Emails.send(params) ``` ```go Go {19-20} theme={null} import ( "fmt" "os" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") pwd, _ := os.Getwd() f, err := os.ReadFile(pwd + "/static/invoice.pdf") if err != nil { panic(err) } attachment := &resend.Attachment{ Content: f, Filename: "invoice.pdf", } params := &resend.SendEmailRequest{ From: "AcmeThanks for the payment
", Attachments: []*resend.Attachment{attachment}, } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust {22} theme={null} use std::fs::File; use std::io::Read; use resend_rs::types::{Attachment, CreateEmailBaseOptions}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "AcmeThanks for the payment
") .with_attachment(Attachment::from_content(invoice).with_filename(filename)); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {8-9} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); Attachment att = Attachment.builder() .fileName("invoice.pdf") .content("invoiceBuffer") .build(); CreateEmailOptions params = CreateEmailOptions.builder() .from("AcmeThanks for the payment
") .attachments(att) .build(); CreateEmailOptions params = CreateEmailOptions.builder() } } ``` ```csharp .NET {15-19} theme={null} using Resend; using System.Collections.Generic; using System.IO; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var message = new EmailMessage() { From = "AcmeThanks for the payment
", }; message.Attachments = new ListThanks for the payment
", "attachments": [ { "content": "UmVzZW5kIGF0dGFjaG1lbnQgZXhhbXBsZS4gTmljZSBqb2Igc2VuZGluZyB0aGUgZW1haWwh%", "filename": "invoice.txt" } ] }' ```it works!
', }, ], { batchValidation: 'permissive', }, ); ``` ```php PHP {19} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->batch->send( [ [ 'from' => 'Acmeit works!
', ] ], [ 'batch_validation' => 'permissive', ] ); ``` ```py Python {22} theme={null} import resend from typing import List resend.api_key = "re_xxxxxxxxx" params: List[resend.Emails.SendParams] = [ { "from": "Acmeit works!
", } ] options: resend.Batch.SendOptions = { "batch_validation": "permissive", } resend.Batch.send(params, options) ``` ```rb Ruby {22} theme={null} require "resend" Resend.api_key = 're_xxxxxxxxx' params = [ { "from": "Acmeit works!
", } ] Resend::Batch.send( params, options: { batch_validation: "permissive" } ) ``` ```go Go {32} theme={null} package examples import ( "fmt" "os" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") var batchEmails = []*resend.SendEmailRequest{ { From: "Acmeit works!
", }, } options := &resend.BatchSendEmailOptions{ BatchValidation: "permissive", } sent, err := client.Batch.SendWithOptions(ctx, batchEmails, options) if err != nil { panic(err) } fmt.Println(sent.Data) } ``` ```rust Rust {25} theme={null} use resend_rs::types::{BatchValidation, CreateEmailBaseOptions}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let emails = vec![ CreateEmailBaseOptions::new( "Acmeit works!
"), ]; let _emails = resend .batch .send_with_batch_validation(emails, BatchValidation::Permissive) .await?; Ok(()) } ``` ```java Java {23} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions firstEmail = CreateEmailOptions.builder() .from("Acmeit works!
") .build(); RequestOptions options = RequestOptions.builder() .add("x-batch-validation", "permissive") .build(); CreateBatchEmailsResponse data = resend.batch() .send( Arrays.asList(firstEmail, secondEmail), options ); } } ``` ```csharp .NET {5} theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var key = BatchValidation.Newit works!
", }; var mail2 = new EmailMessage() { From = "Acmeit works!
", }; var resp = await resend.EmailBatchAsync( [ mail1, mail2 ], EmailBatchValidationMode.Permissive ); Console.WriteLine( "Nr Emails={0}", resp.Content.Data.Count ); if ( resp.Content.Errors?.Count > 0 ) { foreach ( var error in resp.Content.Errors ) { Console.WriteLine( "Error at index {0}: {1}", error.Index, error.Message ); } } ``` ```bash cURL {4} theme={null} curl -X POST 'https://api.resend.com/emails/batch' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -H 'x-batch-validation: permissive' \ -d $'[ { "from": "Acmeit works!
" } ]' ```it works!
', headers: { 'X-Entity-Ref-ID': 'xxx_xxxx', }, }); ``` ```php PHP {9} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'Acmeit works!
', 'headers' => [ 'X-Entity-Ref-ID' => 'xxx_xxxx', ] ]); ``` ```python Python {11} theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Emails.SendParams = { "from": "onboarding@resend.dev", "to": ["delivered@resend.dev"], "subject": "hi", "html": "it works!
", "headers": { "X-Entity-Ref-ID": "xxx_xxxx" } } email = resend.Emails.send(params) print(email) ``` ```rb Ruby {11} theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "from": "Acmeit works!
", "headers": { "X-Entity-Ref-ID": "123" }, } sent = Resend::Emails.send(params) puts sent ``` ```go Go {17} theme={null} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.SendEmailRequest{ From: "Acmeit works!
", Headers: map[string]string{ "X-Entity-Ref-ID": "xxx_xxxx", } } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust {14} theme={null} use resend_rs::types::{Attachment, CreateEmailBaseOptions, Tag}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "Acmeit works!
") .with_header("X-Entity-Ref-ID", "xxx_xxxx"); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {13} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions params = CreateEmailOptions.builder() .from("Acmeit works!
") .headers(Map.of( "X-Entity-Ref-ID", "xxx_xxxx" )) .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```csharp .NET {12-15} theme={null} using Resend; using System.Collections.Generic; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var message = new EmailMessage() { From = "Acmeit works!
", Headers = new Dictionaryit works!
", "headers": { "X-Entity-Ref-ID": "xxx_xxxx" } }' ```Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
Here is our inline logo
it works!
', }, { idempotencyKey: 'welcome-user/123456789', }, ); ``` ```php PHP {9} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'Acmeit works!
', ], [ 'idempotency_key' => 'welcome-user/123456789', ]); ``` ```python Python {9} theme={null} params: resend.Emails.SendParams = { "from": "Acmeit works!
" } options: resend.Emails.SendOptions = { "idempotency_key": "welcome-user/123456789", } resend.Emails.send(params, options) ``` ```rb Ruby {9} theme={null} params = { "from": "Acmeit works!
" } Resend::Emails.send( params, options: { idempotency_key: "welcome-user/123456789" } ) ``` ```go Go {9} theme={null} ctx := context.TODO() params := &resend.SendEmailRequest{ From: "onboarding@resend.dev", To: []string{"delivered@resend.dev"}, Subject: "hello world", Html: "it works!
", } options := &resend.SendEmailOptions{ IdempotencyKey: "welcome-user/123456789", } _, err := client.Emails.SendWithOptions(ctx, params, options) if err != nil { panic(err) } ``` ```rust Rust {14} theme={null} use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "Acmeit works!
") .with_idempotency_key("welcome-user/123456789"); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {9} theme={null} CreateEmailOptions params = CreateEmailOptions.builder() .from("Acmeit works!
") .build(); RequestOptions options = RequestOptions.builder() .setIdempotencyKey("welcome-user/123456789").build(); CreateEmailResponse data = resend.emails().send(params, options); ``` ```csharp C# {11} theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var key = IdempotencyKey.Newit works!
", } ); Console.WriteLine( "Email Id={0}", resp.Content ); ``` ```bash cURL {4} theme={null} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: welcome-user/123456789' \ -d $'{ "from": "Acmeit works!
" }' ``` ```yaml SMTP {4} theme={null} From: Acmeit works!
```it works!
', }, ], { idempotencyKey: 'team-quota/123456789', }, ); ``` ```php PHP {19} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->batch->send( [ [ 'from' => 'Acmeit works!
', ] ], [ 'idempotency_key' => 'team-quota/123456789', ] ); ``` ```py Python {22} theme={null} import resend from typing import List resend.api_key = "re_xxxxxxxxx" params: List[resend.Emails.SendParams] = [ { "from": "Acmeit works!
", } ] options: resend.Batch.SendOptions = { "idempotency_key": "team-quota/123456789", } resend.Batch.send(params, options) ``` ```rb Ruby {22} theme={null} require "resend" Resend.api_key = 're_xxxxxxxxx' params = [ { "from": "Acmeit works!
", } ] Resend::Batch.send( params, options: { idempotency_key: "team-quota/123456789" } ) ``` ```go Go {32} theme={null} package examples import ( "fmt" "os" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") var batchEmails = []*resend.SendEmailRequest{ { From: "Acmeit works!
", }, } options := &resend.BatchSendEmailOptions{ IdempotencyKey: "team-quota/123456789", } sent, err := client.Batch.SendWithOptions(ctx, batchEmails, options) if err != nil { panic(err) } fmt.Println(sent.Data) } ``` ```rust Rust {23} theme={null} use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let emails = vec![ CreateEmailBaseOptions::new( "Acmeit works!
"), ]; let _emails = resend.batch.send_with_idempotency_key(emails, "team-quota/123456789").await?; Ok(()) } ``` ```java Java {23} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions firstEmail = CreateEmailOptions.builder() .from("Acmeit works!
") .build(); CreateBatchEmailsResponse data = resend.batch().send( Arrays.asList(firstEmail, secondEmail), Map.of("idempotency_key", "team-quota/123456789") ); } } ``` ```csharp .NET {5} theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var key = IdempotencyKey.Newit works!
", }; var mail2 = new EmailMessage() { From = "Acmeit works!
", }; var resp = await resend.EmailBatchAsync(key, [ mail1, mail2 ] ); Console.WriteLine( "Nr Emails={0}", resp.Content.Count ); ``` ```bash cURL {4} theme={null} curl -X POST 'https://api.resend.com/emails/batch' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: team-quota/123456789' \ -d $'[ { "from": "Acmeit works!
" } ]' ```it works!
', scheduledAt: 'in 1 min', }); ``` ```php PHP {8} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'Acmeit works!
', 'scheduled_at' => 'in 1 min' ]); ``` ```python Python {10} theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Emails.SendParams = { "from": "Acmeit works!
", "scheduled_at": "in 1 min" } resend.Emails.send(params) ``` ```rb Ruby {10} theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "from": "Acmeit works!
", "scheduled_at": "in 1 min" } Resend::Emails.send(params) ``` ```go Go {16} theme={null} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.SendEmailRequest{ From: "Acmeit works!
", ScheduledAt: "in 1 min" } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust {14} theme={null} use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "Acmeit works!
") .with_scheduled_at("in 1 min"); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {12} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions params = CreateEmailOptions.builder() .from("Acmeit works!
") .scheduledAt("in 1 min") .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```csharp .NET {11} theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailSendAsync( new EmailMessage() { From = "Acmeit works!
", MomentSchedule = "in 1 min", } ); Console.WriteLine( "Email Id={0}", resp.Content ); ``` ```bash cURL {9} theme={null} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "from": "Acmeit works!
", "scheduled_at": "in 1 min" }' ```it works!
', scheduledAt: oneMinuteFromNow, }); ``` ```php PHP {3} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $oneMinuteFromNow = (new DateTime())->modify('+1 minute')->format(DateTime::ISO8601); $resend->emails->send([ 'from' => 'Acmeit works!
', 'scheduled_at' => $oneMinuteFromNow ]); ``` ```python Python {6} theme={null} import resend from datetime import datetime, timedelta resend.api_key = "re_xxxxxxxxx" one_minute_from_now = (datetime.now() + timedelta(minutes=1)).isoformat() params: resend.Emails.SendParams = { "from": "Acmeit works!
", "scheduled_at": one_minute_from_now } resend.Emails.send(params) ``` ```rb Ruby {5} theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" one_minute_from_now = (Time.now + 1 * 60).strftime("%Y-%m-%dT%H:%M:%S.%L%z") params = { "from": "Acmeit works!
", "scheduled_at": one_minute_from_now } Resend::Emails.send(params) ``` ```go Go {12} theme={null} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") oneMinuteFromNow := time.Now().Add(time.Minute * time.Duration(1)) oneMinuteFromNowISO := oneMinuteFromNow.Format("2006-01-02T15:04:05-0700") params := &resend.SendEmailRequest{ From: "Acmeit works!
", ScheduledAt: oneMinuteFromNowISO } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust {12-15} theme={null} use chrono::{Local, TimeDelta}; use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "Acmeit works!
") .with_scheduled_at(&one_minute_from_now); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {7-10} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); String oneMinuteFromNow = Instant .now() .plus(1, ChronoUnit.MINUTES) .toString(); CreateEmailOptions params = CreateEmailOptions.builder() .from("Acmeit works!
") .scheduledAt(oneMinuteFromNow) .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```csharp .NET {11} theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailSendAsync( new EmailMessage() { From = "Acmeit works!
", MomentSchedule = DateTime.UtcNow.AddMinutes( 1 ), } ); Console.WriteLine( "Email Id={0}", resp.Content ); ``` ```bash cURL {9} theme={null} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "from": "Acmeit works!
", "scheduled_at": "2024-08-20T11:52:01.858Z" }' ```it works!
', tags: [ { name: 'category', value: 'confirm_email', }, ], }); ``` ```php PHP {8-13} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'Acmeit works!
', 'tags' => [ [ 'name' => 'category', 'value' => 'confirm_email', ], ] ]); ``` ```python Python {10-12} theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Emails.SendParams = { "from": "Acmeit works!
", "tags": [ {"name": "category", "value": "confirm_email"}, ], } email = resend.Emails.send(params) print(email) ``` ```rb Ruby {10-12} theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "from": "Acmeit works!
", "tags": [ {"name": "category", "value": "confirm_email"} ] } sent = Resend::Emails.send(params) puts sent ``` ```go Go {16} theme={null} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.SendEmailRequest{ From: "Acmeit works!
", Subject: "hello world", Tags: []resend.Tag{{Name: "category", Value: "confirm_email"}}, } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust {14} theme={null} use resend_rs::types::{CreateEmailBaseOptions, Tag}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "Acmeit works!
") .with_tag(Tag::new("category", "confirm_email")); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {17} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); Tag tag = Tag.builder() .name("category") .value("confirm_email") .build(); SendEmailRequest sendEmailRequest = SendEmailRequest.builder() .from("Acmeit works!
") .tags(tag) .build(); SendEmailResponse data = resend.emails().send(sendEmailRequest); } } ``` ```csharp .NET {12} theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailSendAsync( new EmailMessage() { From = "Acmeit works!
", ReplyTo = "onboarding@resend.dev", Tags = new Listit works!
", "tags": [ { "name": "category", "value": "confirm_email" } ] }' ```it works!
', tags: [ { name: 'category', value: 'confirm_email', }, ], }, ]); ``` ```php PHP {9-13,21-25} theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->batch->send([ [ 'from' => 'Acmeit works!
', 'tags' => [ [ 'name' => 'category', 'value' => 'confirm_email' ] ] ] ]); ``` ```py Python {12-17,24-29} theme={null} import resend from typing import List resend.api_key = "re_xxxxxxxxx" params: List[resend.Emails.SendParams] = [ { "from": "Acmeit works!
", "tags": [ { "name": "category", "value": "confirm_email" } ] } ] resend.Batch.send(params) ``` ```rb Ruby {11-16,23-28} theme={null} require "resend" Resend.api_key = 're_xxxxxxxxx' params = [ { "from": "Acmeit works!
", "tags": [ { "name": "category", "value": "confirm_email" } ] } ] Resend::Batch.send(params) ``` ```go Go {22,29} theme={null} package examples import ( "fmt" "os" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") var batchEmails = []*resend.SendEmailRequest{ { From: "Acmeit works!
", Tags: []resend.Tag{{Name: "category", Value: "confirm_email"}}, }, } sent, err := client.Batch.SendWithContext(ctx, batchEmails) if err != nil { panic(err) } fmt.Println(sent.Data) } ``` ```rust Rust {15,22} theme={null} use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let emails = vec![ CreateEmailBaseOptions::new( "Acmeit works!
") .with_tag(Tag::new("category", "confirm_email")), ]; let _emails = resend.batch.send(emails).await?; Ok(()) } ``` ```java Java {12-15,23-26} theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions firstEmail = CreateEmailOptions.builder() .from("Acmeit works!
") .tags(Tag.builder() .name("category") .value("confirm_email") .build()) .build(); CreateBatchEmailsResponse data = resend.batch().send( Arrays.asList(firstEmail, secondEmail) ); } } ``` ```csharp .NET {11,20} theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var mail1 = new EmailMessage() { From = "Acmeit works!
", Tags = new Listit works!
", Tags = new Listit works!
", "tags": [ { "name": "category", "value": "confirm_email" } ] } ]' ```You have successfully signed up to example.com,
To log in to the site, just follow this link: <%= @url %>.
Thanks for joining and have a great day!
``` Initialize your `UserMailer` class. This should return a `UserMailer` instance. ```rb theme={null} u = User.new name: "derich" mailer = UserMailer.with(user: u).welcome_email # => #You have successfully signed up to example.com,
To log in to the site, just follow this link: <%= @url %>.
Thanks for joining and have a great day!
``` Initialize your `UserMailer` class. This should return a `UserMailer` instance. ```rb theme={null} u = User.new name: "derich" mailer = UserMailer.with(user: u).welcome_email # => #it works!
``` Learn more about [idempotency keys](/dashboard/emails/idempotency-keys). ## Custom Headers If your SMTP client supports it, you can add custom headers to your emails. Here are some common use cases for custom headers: * Prevent threading on Gmail with the `X-Entity-Ref-ID` header * Include a shortcut for users to unsubscribe with the `List-Unsubscribe` header ## FAQ Once configured, you should be able to start sending emails via SMTP. Below are some frequently asked questions:Hello world
', }); if (error) { return Response.json({ error }, { status: 500 }); } return Response.json({ data }); } catch (error) { return Response.json({ error }, { status: 500 }); } } ```