pub struct Client { /* private fields */ }Expand description
Async client for Plunk’s transactional email API.
use plunk_rs::{Client, Email, EmailAddress};
let client = Client::new("sk_your_secret_key")?;
let email = Email::html("user@example.com", "Welcome", "<h1>Hello</h1>")?
.from(EmailAddress::named("My App", "hello@example.com")?)?
.reply_to("support@example.com")?;
let response = client.send(&email).await?;
assert_eq!(response.deliveries().len(), 1);Implementations§
Source§impl Client
impl Client
Sourcepub fn new(api_key: impl Into<String>) -> Result<Self>
pub fn new(api_key: impl Into<String>) -> Result<Self>
Creates a client that targets Plunk’s hosted API.
Sourcepub fn builder(api_key: impl Into<String>) -> ClientBuilder
pub fn builder(api_key: impl Into<String>) -> ClientBuilder
Creates a builder for custom HTTP clients or self-hosted Plunk URLs.
Sourcepub async fn send(&self, email: &Email) -> Result<SendResponse>
pub async fn send(&self, email: &Email) -> Result<SendResponse>
Sends a validated email via POST /v1/send.
pub fn base_url(&self) -> &Url
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more