[−][src]Struct sendgrid::SGClient
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
impl SGClient
[src]
pub fn new<S: Into<String>>(key: S) -> SGClient
[src]
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.
pub fn send(&self, mail_info: Mail<'_>) -> SendgridResult<Response>
[src]
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
ⓘThis example is not tested
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 Send for SGClient
impl Sync for SGClient
impl Unpin for SGClient
impl !UnwindSafe for SGClient
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,