Struct sendgrid::SGClient [−][src]
pub struct SGClient { /* fields omitted */ }
Expand description
This is the struct that allows you to authenticate to the SendGrid API. It contains the API key which allows you to send messages as well as a blocking request client.
Implementations
Makes a new SendGrid cient with the specified API key. This will panic if you are using the default TLS backend and do not have a default TLS backend available. If you are using the RustTLS backend, this can never panic because RustTLS is statically linked.
Sends a messages through the SendGrid API. It takes a Mail struct as an argument. It returns the string response from the API as JSON.
Example
ⓘ
use sendgrid::SendgridError; fn main() -> Result<(), SendgridError> { let my_secret_key = std::env::var("SENDGRID_KEY").expect("need SENDGRID_KEY to test"); use sendgrid::{Mail, SGClient}; let mail = Mail::new() .add_from("my-email@address.com") .add_text("hi!") .add_subject("Hello") .add_to(("your-email@address.com", "Your Name").into()); let response = SGClient::new(my_secret_key) .send(mail)?; Ok(()) }
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for SGClient
impl !UnwindSafe for SGClient
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more