pub fn send(&self, mail_info: Mail) -> SendgridResult<String> {
        use reqwest::blocking::Client;

        let client = Client::new();
        let mut headers = HeaderMap::new();
        headers.insert(
            header::AUTHORIZATION,
            HeaderValue::from_str(&format!("Bearer {}", self.api_key.clone()))?,
        );
        headers.insert(
            header::CONTENT_TYPE,
            HeaderValue::from_static("application/x-www-form-urlencoded"),
        );
        headers.insert(header::USER_AGENT, HeaderValue::from_static("sendgrid-rs"));

        let post_body = make_post_body(mail_info)?;
        let res = client
            .post(API_URL)
            .headers(headers)
            .body(post_body)
            .send()?;

        if !res.status().is_success() {
            Err(SendgridError::RequestNotSuccessful(res.status()))
        } else {
            Ok(res.text()?)
        }
    }
/// 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.
/// It sets the Content-Type to be application/x-www-form-urlencoded.
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.
It sets the Content-Type to be application/x-www-form-urlencoded.
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 . It sets the Content - Type to be application / x - www - form - urlencoded .
pub fn send(&self, mail_info: Mail) -> SendgridResult<String> {
        use reqwest::blocking::Client;
        let client = Client::new();
        let mut headers = HeaderMap::new();
        headers.insert(
            header::AUTHORIZATION,
            HeaderValue::from_str(&format!("Bearer {}", self.api_key.clone()))?,
        );
        headers.insert(
            header::CONTENT_TYPE,
            HeaderValue::from_static("application/x-www-form-urlencoded"),
        );
        headers.insert(header::USER_AGENT, HeaderValue::from_static("sendgrid-rs"));
        let post_body = make_post_body(mail_info)?;
        let res = client
            .post(API_URL)
            .headers(headers)
            .body(post_body)
            .send()?;
        if !res.status().is_success() {
            Err(SendgridError::RequestNotSuccessful(res.status()))
        } else {
            Ok(res.text()?)
        }
    }
pub fn send ( & self , mail_info : Mail ) -> SendgridResult < String > { use reqwest :: blocking :: Client ; let client = Client :: new ( ) ; let mut headers = HeaderMap :: new ( ) ; headers . insert ( header :: AUTHORIZATION , HeaderValue :: from_str ( & format ! ( " " self api_key clone ( ) ) ) ? , ) ; headers . insert ( header :: CONTENT_TYPE , HeaderValue :: from_static ( " " ) , ) ; headers . insert ( header :: USER_AGENT , HeaderValue :: from_static ( " " ) ) ; let post_body = make_post_body ( mail_info ) ? ; let res = client . post ( API_URL ) . headers ( headers ) . body ( post_body ) . send ( ) ? ; if ! res . status ( ) . is_success ( ) { Err ( SendgridError :: RequestNotSuccessful ( res . status ( ) ) ) } else { Ok ( res . text ( ) ? ) } }
Sends a messages through the SendGrid API.
Sends a messages through the SendGrid API .
&self
mail_info
Mail
&self
mail_info
Mail