#gmail #send-email #google-api #service-account #api-service #blocking

rust-gmail

A simple crate to send emails using the Gmail API

6 releases

0.2.1 Aug 15, 2023
0.2.0 Aug 12, 2023
0.1.3 Aug 12, 2023

#153 in Email

48 downloads per month

MIT license

18KB
358 lines

Rust-gmail

Crates.io Documentation MIT licensed

Simple Rust crate for sending emails via the GMAIL Api and a Google cloud service account.


lib.rs:

A Rust library to interact with the google Gmail API using a service account.

Currently focused only on support for sending emails but this may change in the future. Available both as async (default) or as blocking using the "blocking" feature.

Note that usage of this lib will require a google API service account with domain wide delegation for gmail setup with a google cloud project with the gmail API enabled. Links for more information:

Features

There is currently only one feature, blocking which will add blocking alternatives to all async functions with the same name suffixed with _blocking. E.g. send_email_blocking instead of send_email.

Examples

Examples of how to use this crate.

Async Example

let email_client = GmailClient::builder(
    "service_account.json",
    "noreply@example.test",
)?
.build()
.await?;

email_client
    .send_email("some_user@domain.test")
    .await?;

Blocking Example

Note: Requires the blocking feature.

let email_client = GmailClient::builder(
    "service_account.json",
    "noreply@example.test",
)?
.build_blocking()?;

email_client
    .send_email_blocking("some_user@domain.test")?;

Dependencies

~7–24MB
~394K SLoC