1 unstable release

0.1.0 Oct 25, 2020

#338 in Email

MIT license

17KB
356 lines

postal-rs

A libarry which wraps HTTP API of Postal. It uses https://krystal.github.io/postal-api/controllers/messages.html as a source of documentation.

Get started

use postal_rs::{Client, DetailsInterest, Message, SendResult};
use std::env;

#[tokio::main]
async fn main() {
   let address = env::var("POSTAL_ADDRESS").unwrap_or_default();
   let token = env::var("POSTAL_TOKEN").unwrap_or_default();

   let message = Message::default()
       .to(&["example@gmail.com".to_owned()])
       .from("test@yourserver.io")
       .subject("Hello World")
       .text("A test message");
   let client = Client::new(address, token).unwrap();
   let _ = client
       .send(message)
       .await
       .unwrap();
}

lib.rs:

The crate provides an interface to Postal's http API.

Examples

use postal_rs::{Client, DetailsInterest, Message, SendResult};
use std::env;

#[tokio::main]
async fn main() {
   let address = env::var("POSTAL_ADDRESS").unwrap_or_default();
   let token = env::var("POSTAL_TOKEN").unwrap_or_default();

   let message = Message::default()
       .to(&["example@gmail.com".to_owned()])
       .from("test@yourserver.io")
       .subject("Hello World")
       .text("A test message");
   let client = Client::new(address, token).unwrap();
   let _ = client
       .send(message)
       .await
       .unwrap();
}

Dependencies

~3–7MB
~168K SLoC