#gmail #temp-mail #api-wrapper #api-bindings

yanked gmailnator

An unofficial api wrapper to interact with https://gmailnator.com/

0.2.1 Nov 22, 2020
0.2.0 Nov 15, 2020
0.1.5 Oct 31, 2020

#15 in #gmail

GPL-3.0-only

24KB
398 lines

Generic badge Generic badge

Please refer to the documentation at docs.rs for up to date examples.


lib.rs:

This library contains objects to create a gmailnator inbox and read the messages it contains.

Getting started :

The main struct is the GmailnatorInbox struct, one instance contains one inbox associated to an email address.

This creates a new temporary gmail address :

use gmailnator::GmailnatorInbox;

let inbox = GmailnatorInbox::new().unwrap();

To get the associated mail address :

let address:&str = inbox.get_address();

This creates n number of addresses, it must be used to create a large number of inboxes.

use gmailnator::GmailnatorInbox;

let n:u32 = 500;
let inboxes:Vec<GmailnatorInbox> = GmailnatorInbox::new_bulk(n).unwrap();

assert_eq!(inboxes.len() as u32, n); 

Retrieve messages in a vector and display them via the container struct MailMessage:

use gmailnator::{GmailnatorInbox, MailMessage};
let messages:Vec<MailMessage> = inbox.get_messages_iter().unwrap().collect();

for message in messages {

    let title = message.get_subject();

    let raw_body = message.get_raw_content();
    let decoded_body = message.decode_content().unwrap();

    // raw_body     = &lt;You&gt; Where did you put the &quot;thing&quot; ?
    // decoded_body = <You> Where did you put the "thing" ?

    println!("Title : {}\nBody : {}", title, decoded_body);

}

To search for a particular message, use the MailMessageIterator :

use gmailnator::{GmailnatorInbox, MailMessage, MailMessageIterator};
let mut messages_iter:MailMessageIterator = inbox.get_messages_iter().unwrap();

let find_result = messages_iter.find(|m| m.get_subject() == "Confirm your order");

if let Some(confirmation_message) = find_result {

  //Confirm your order :)

}

Dependencies

~9–16MB
~215K SLoC