Struct smtpapi::Header [] [src]

pub struct Header {
    // some fields omitted
}

Methods

impl Header

fn new() -> Header

Constructs a new Header.

Examples

use smtpapi::{Header};

let header = Header::new();
println!("{}", header.to_json_string());

fn to_json_string(&self) -> String

Returns the JSON String reprezentation of Header.

Examples

use smtpapi::{Header};

let header = Header::new();
println!("{}", header.to_json_string());

fn add_to<S>(&mut self, email: S) -> &mut Header where S: Into<String>

It appends a single email to the To header

Examples

use smtpapi::{Header};

let mut header = Header::new();
header.add_to("email@domain.com");

fn add_tos<S>(&mut self, emails: Vec<S>) -> &mut Header where S: Into<String>

It appends multiple emails to the To header

Examples

use smtpapi::{Header};

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

fn set_tos<S>(&mut self, emails: Vec<S>) -> &mut Header where S: Into<String>

It sets the value of the To header

Examples

use smtpapi::{Header};

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

fn add_substitution<S>(&mut self, key: S, sub: S) -> &mut Header where S: Into<String>

It adds a new substitution to a specific key

Examples

use smtpapi::{Header};

let mut header = Header::new();
header.add_substitution("[name]", "my_name");

fn add_substitutions<S>(&mut self, key: S, subs: Vec<&str>) -> &mut Header where S: Into<String>

It adds a multiple substitutions to a specific key

Examples

use smtpapi::{Header};

let mut header = Header::new();
header.add_substitutions("[name]", vec!["my_name_1", "my_name_2"]);

fn set_substitutions(&mut self, subs: HashMap<String, Vec<String>>) -> &mut Header

It sets the value of the substitutions on the Sub header

Examples

use smtpapi::{Header};
use std::collections::HashMap;

let mut header = Header::new();
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);

fn add_section<S>(&mut self, section: S, value: S) -> &mut Header where S: Into<String>

It sets the value for a specific section

Examples

use smtpapi::{Header};

let mut header = Header::new();
header.add_section("-top-", "sample");

fn set_sections(&mut self, sections: HashMap<String, String>) -> &mut Header

It sets the value for the Section header

Examples

use smtpapi::{Header};
use std::collections::HashMap;

let mut header = Header::new();
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);

fn add_category<S>(&mut self, category: S) -> &mut Header where S: Into<String>

It adds a new category to the Category header

Examples

use smtpapi::{Header};

let mut header = Header::new();
header.add_category("welcome");

fn add_categories<S>(&mut self, categories: Vec<S>) -> &mut Header where S: Into<String>

It adds multiple categories to the Category header

Examples

use smtpapi::{Header};

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

fn set_categories<S>(&mut self, categories: Vec<S>) -> &mut Header where S: Into<String>

It sets the value of the Categories field

Examples

use smtpapi::{Header};

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

fn add_unique_arg<S>(&mut self, unique_arg: S, value: S) -> &mut Header where S: Into<String>

It sets the value of a specific unique argument

Examples

use smtpapi::{Header};

let mut header = Header::new();
header.add_unique_arg("account_id", "123412-121-1212");

fn set_unique_args(&mut self, unique_args: HashMap<String, String>) -> &mut Header

It will set the value of the Unique_args header

Examples

use smtpapi::{Header};
use std::collections::HashMap;

let mut header = Header::new();
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);

fn add_filter<S>(&mut self, filter_name: S, setting: S, value: S) -> &mut Header where S: Into<String>

It will set the specific setting for a filter

Examples

use smtpapi::{Header};

let mut header = Header::new();
header.add_filter("clicktrack", "enabled", "1")
      .add_filter("opentrack", "enabled", "1");

fn set_filter<S>(&mut self, filter: S, setting: Filter) -> &mut Header where S: Into<String>

It takes in a Filter struct with predetermined settings and sets it for such Filter key

Examples

use smtpapi::{Header, Filter};

let mut header = Header::new();
let mut filter = Filter::new();
filter.add_setting("enabled", "1");

header.set_filter("clicktrack", filter);

fn set_ip_pool<S>(&mut self, name: S) -> &mut Header where S: Into<String>

It sets the value of the IpPool field

Examples

use smtpapi::{Header};

let mut header = Header::new();

header.set_ip_pool("newsletter_pool");

fn set_asm_group_id(&mut self, asm_group_id: i32) -> &mut Header

It will set the value of the ASMGroupID field

Examples

use smtpapi::{Header};

let mut header = Header::new();

header.set_asm_group_id(1221);

fn set_send_at(&mut self, send_at: i64) -> &mut Header

It takes in a timestamp which determines when the email will be sent

Examples

use smtpapi::{Header};

let mut header = Header::new();

header.set_send_at(1453213937);

fn add_send_each_at(&mut self, send_at: i64) -> &mut Header

It takes in a timestamp and pushes it into a list. Must match length of To emails

Examples

use smtpapi::{Header};

let mut header = Header::new();

header.add_send_each_at(1453213937)
      .add_send_each_at(1453213939);

fn set_send_each_at(&mut self, send_each_at: Vec<i64>) -> &mut Header

It takes an array of timestamps. Must match length of To emails

Examples

use smtpapi::{Header};

let mut header = Header::new();

header.set_send_each_at(vec![1453213939, 1453213932, 1453213933]);

Trait Implementations

impl Drop for Header

fn drop(&mut self)

impl ToJson for Header

fn to_json(&self) -> Json

impl Display for Header

Implement Display for Header

fn fmt(&self, f: &mut Formatter) -> Result

Derived Implementations

impl Clone for Header

fn clone(&self) -> Header

fn clone_from(&mut self, source: &Self)

impl Debug for Header

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Encodable for Header

fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>

impl Decodable for Header

fn decode<__D: Decoder>(__arg_0: &mut __D) -> Result<Header, __D::Error>