Crate sendgrid_api[][src]

A rust library for interacting with the SendGrid v3 API.

For more information, the SendGrid v3 API is documented at sendgrid.com/docs/API_Reference/api_v3.html.

Example:

use sendgrid_api::SendGrid;

async fn send_email() {
    // Initialize the SendGrid client.
    let sendgrid = SendGrid::new_from_env();

    // Send the email.
    sendgrid
        .send_mail(
            "email subject".to_string(),
            "body of email".to_string(),
            vec!["to_address@domain.com".to_string()],
            vec!["cc_address@domain.com".to_string()],
            vec!["bcc_address@domain.com".to_string()],
            "from_address@domain.com".to_string(),
        )
        .await;

    println!("successfully sent the email!");
}

Structs

Attachment

An attachment block for a V3 message. Content and filename are required. If the mime_type is unspecified, the email will use Sendgrid’s default for attachments which is ‘application/octet-stream’.

Content

The body of an email with the content type and the message.

Email

An email with a required address and an optional name field.

Message

The main structure for a V3 API mail send call. This is composed of many other smaller structures used to add lots of customization to your message.

Personalization

A personalization block for a V3 message. It has to at least contain one email as a to address. All other fields are optional.

SendGrid

Entrypoint for interacting with the SendGrid API.