it works!
', }, ]); ``` ```php PHP $resend = Resend::client('re_123456789'); $resend->batch->send([ [ 'from' => 'Acmeit works!
', ] ]); ``` ```py Python import resend from typing import List resend.api_key = "re_123456789" params: List[resend.Emails.SendParams] = [ { "from": "Acmeit works!
", } ] resend.Batch.send(params) ``` ```rb Ruby require "resend" Resend.api_key = 're_123456789' params = [ { "from": "Acmeit works!
", } ] Resend::Batch.send(params) ``` ```go Go package examples import ( "fmt" "os" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_123456789") 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 use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_123456789"); let emails = vec![ CreateEmailBaseOptions::new( "Acmeit works!
"), ]; let _emails = resend.batch.send(emails).await?; Ok(()) } ``` ```java Java import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_123456789"); CreateEmailOptions firstEmail = CreateEmailOptions.builder() .from("Acmeit works!
") .build(); CreateBatchEmailsResponse data = resend.batch().send( Arrays.asList(firstEmail, secondEmail) ); } } ``` ```bash cURL curl -X POST 'https://api.resend.com/emails/batch' \ -H 'Authorization: Bearer re_123456789' \ -H 'Content-Type: application/json' \ -d $'[ { "from": "Acmeit works!
" } ]' ```it works!
', }); ``` ```php PHP $resend = Resend::client('re_123456789'); $resend->emails->send([ 'from' => 'Acmeit works!
' ]); ``` ```python Python import resend resend.api_key = "re_123456789" params: resend.Emails.SendParams = { "from": "Acmeit works!
" } email = resend.Emails.send(params) print(email) ``` ```rb Ruby require "resend" Resend.api_key = "re_123456789" params = { "from": "Acmeit works!
" } sent = Resend::Emails.send(params) puts sent ``` ```go Go import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_123456789") params := &resend.SendEmailRequest{ From: "Acmeit works!
" } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust use resend_rs::types::{CreateEmailBaseOptions}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_123456789"); let from = "Acmeit works!
"; let email = CreateEmailBaseOptions::new(from, to, subject) .with_html(html); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_123456789"); CreateEmailOptions params = CreateEmailOptions.builder() .from("Acmeit works!
") .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```bash cURL curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_123456789' \ -H 'Content-Type: application/json' \ -d $'{ "from": "Acmeit works!
" }' ```Thanks for the payment
', attachments: [ { path: 'https://resend.com/static/sample/invoice.pdf', filename: 'invoice.pdf', }, ], }); ``` ```php PHP {10-11} $resend = Resend::client('re_123456789'); $resend->emails->send([ 'from' => 'AcmeThanks for the payment
', 'attachments' => [ [ 'path' => 'https://resend.com/static/sample/invoice.pdf', 'filename' => 'invoice.pdf' ] ] ]); ``` ```python Python {6-7} import resend resend.api_key = "re_123456789" attachment: resend.Attachment = { "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} require "resend" Resend.api_key = "re_123456789" 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} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_123456789") 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} use resend_rs::types::{Attachment, CreateEmailBaseOptions}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_123456789"); 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} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_123456789"); 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); } } ``` ```bash cURL {11-12} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_123456789' \ -H 'Content-Type: application/json' \ -d $'{ "from": "AcmeThanks 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} $resend = Resend::client('re_123456789'); $resend->emails->send([ 'from' => 'AcmeThanks for the payment
', 'attachments' => [ [ 'filename' => 'invoice.pdf', 'content' => $invoiceBuffer ] ] ]); ``` ```python Python {10} import os import resend resend.api_key = "re_123456789" 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} require "resend" Resend.api_key = "re_123456789" 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} import ( "fmt" "os" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_123456789") 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} 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_123456789"); 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} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_123456789"); 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() } } ``` ```bash cURL {11-12} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_123456789' \ -H 'Content-Type: application/json' \ -d $'{ "from": "AcmeThanks for the payment
", "attachments": [ { "content": "UmVzZW5kIGF0dGFjaG1lbnQgZXhhbXBsZS4gTmljZSBqb2Igc2VuZGluZyB0aGUgZW1haWwh%", "filename": "invoice.txt" } ] }' ```it works!
', scheduledAt: 'in 1 min', }); ``` ```php PHP {8} $resend = Resend::client('re_123456789'); $resend->emails->send([ 'from' => 'Acmeit works!
', 'scheduled_at' => 'in 1 min' ]); ``` ```python Python {10} import resend resend.api_key = "re_123456789" params: resend.Emails.SendParams = { "from": "Acmeit works!
", "scheduled_at": "in 1 min" } resend.Emails.send(params) ``` ```rb Ruby {10} require "resend" Resend.api_key = "re_123456789" params = { "from": "Acmeit works!
", "scheduled_at": "in 1 min" } Resend::Emails.send(params) ``` ```go Go {16} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_123456789") 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} use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_123456789"); let from = "Acmeit works!
") .with_scheduled_at("in 1 min"); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {12} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_123456789"); CreateEmailOptions params = CreateEmailOptions.builder() .from("Acmeit works!
") .scheduledAt("in 1 min") .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```bash cURL {9} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_123456789' \ -H 'Content-Type: application/json' \ -d $'{ "from": "Acmeit works!
", "scheduled_at": "in 1 min" }' ```it works!
', scheduledAt: oneMinuteFromNow, }); ``` ```php PHP {3} $resend = Resend::client('re_123456789'); $oneMinuteFromNow = (new DateTime())->modify('+1 minute')->format(DateTime::ISO8601); $resend->emails->send([ 'from' => 'Acmeit works!
', 'scheduled_at' => $oneMinuteFromNow ]); ``` ```python Python {6} import resend from datetime import datetime, timedelta resend.api_key = "re_123456789" 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} require "resend" Resend.api_key = "re_123456789" 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} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_123456789") 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} 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_123456789"); let from = "Acmeit works!
") .with_scheduled_at(&one_minute_from_now); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {7-10} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_123456789"); 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); } } ``` ```bash cURL {9} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_123456789' \ -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} $resend = Resend::client('re_123456789'); $resend->emails->send([ 'from' => 'Acmeit works!
', 'tags' => [ [ 'name' => 'category', 'value' => 'confirm_email', ], ] ]); ``` ```python Python {10-12} import resend resend.api_key = "re_123456789" params: resend.Emails.SendParams = { "from": "Acmeit works!
", "tags": [ {"name": "category", "value": "confirm_email"}, ], } email = resend.Emails.send(params) print(email) ``` ```rb Ruby {10-12} require "resend" Resend.api_key = "re_123456789" params = { "from": "Acmeit works!
", "tags": [ {"name": "category", "value": "confirm_email"} ] } sent = Resend::Emails.send(params) puts sent ``` ```go Go {16} import ( "fmt" "github.com/resend/resend-go/v2" ) func main() { ctx := context.TODO() client := resend.NewClient("re_123456789") 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} use resend_rs::types::{CreateEmailBaseOptions, Tag}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_123456789"); let from = "Acmeit works!
") .with_tag(Tag::new("category", "confirm_email")); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java {17} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_123456789"); 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); } } ``` ```bash cURL {9-14} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_123456789' \ -H 'Content-Type: application/json' \ -d $'{ "from": "Acmeit works!
", "tags": [ { "name": "category", "value": "confirm_email" } ] }' ```You have successfully signed up to example.com,
To login 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 u = User.new name: "derich" mailer = UserMailer.with(user: u).welcome_email # => #You have successfully signed up to example.com,
To login 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 u = User.new name: "derich" mailer = UserMailer.with(user: u).welcome_email # => #