smtpapi

Crates.iosmtpapi
lib.rssmtpapi
version0.1.3
sourcesrc
created_at2016-01-21 18:57:14.724414
updated_at2016-03-08 13:19:16.525973
descriptionThis crate allows you to quickly and more easily generate SendGrid X-SMTPAPI headers.
homepagehttps://github.com/bsorin/smtpapi-rs
repositoryhttps://github.com/bsorin/smtpapi-rs
max_upload_size
id3944
size38,331
Sorin Baba (bsorin)

documentation

https://bsorin.github.io/doc/0.1/smtpapi/

README

SMTP-API

This crate allows you to quickly and more easily generate SendGrid X-SMTPAPI headers.

BuildStatus Clippy Linting Result

Examples

New Header

use smtpapi::{Header};

let mut header = Header::new();

Recipients

use smtpapi::{Header};

let mut header = Header::new();
header.add_to("email@domain.com");
// or
header.add_tos(vec!["email1@domain.com", "email2@domain.com"]);
// or
header.set_tos(vec!["email1@domain.com", "email2@domain.com"]);

Substitutions

use smtpapi::{Header};

let mut header = Header::new();

header.add_substitution("[name]", "my_name");
// or
header.add_substitutions("[name]", vec!["my_name_1", "my_name_2"]);
// or
let mut all_subs : HashMap<String, Vec<String>> = HashMap::new();
all_subs.insert("-item1-".to_string(), vec!["rust".to_string(), "power".to_string()]);
all_subs.insert("-item2-".to_string(), vec!["rust".to_string(), "power".to_string()]);

header.set_substitutions(all_subs);

Section

use smtpapi::{Header};

let mut header = Header::new();
header.add_section("-top-", "sample");
// or
let mut sections : HashMap<String, String> = HashMap::new();
sections.insert("-item1-".to_string(), "value1".to_string());
sections.insert("-item2-".to_string(), "value2".to_string());

header.set_sections(sections);

Category

use smtpapi::{Header};

let mut header = Header::new();
header.add_category("welcome");
// or
header.add_categories(vec!["welcome", "new_accounts"]);
// or
header.set_categories(vec!["welcome", "new_accounts"]);

Unique Arguments

use smtpapi::{Header};

let mut header = Header::new();
header.add_unique_arg("account_id", "123412-121-1212");
// or
let mut unique_args : HashMap<String, String> = HashMap::new();
unique_args.insert("-arg1-".to_string(), "value1".to_string());
unique_args.insert("-arg2-".to_string(), "value2".to_string());

header.set_unique_args(unique_args);

Filters

use smtpapi::{Header, Filter};

let mut header = Header::new();
header.add_filter("clicktrack", "enabled", "1")
      .add_filter("opentrack", "enabled", "1");
// or
let mut filter = Filter::new();
filter.add_setting("enable", "1")
      .add_setting("text/plain", "You can haz footers!");

header.set_filter("footer", filter);

Send At

use smtpapi::{Header};

let mut header = Header::new();

header.set_send_at(1453213937);
// or
header.set_send_each_at(vec![1453213939, 1453213932, 1453213933]);
// or
header.add_send_each_at(1453213937)
      .add_send_each_at(1453213939);

ASM Group ID

use smtpapi::{Header};

let mut header = Header::new();
header.set_asm_group_id(1221);

IP Pools

use smtpapi::{Header};

let mut header = Header::new();
header.set_ip_pool("newsletter_pool");

JSONString

use smtpapi::{Header};

let mut header = Header::new();
header.to_json_string();

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Running Tests

cargo test
```

## MIT License
Commit count: 12

cargo fmt