smtpapi

Struct Header

Source
pub struct Header { /* private fields */ }

Implementations§

Source§

impl Header

Source

pub fn new() -> Header

Constructs a new Header.

§Examples
use smtpapi::{Header};

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

pub 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());
Source

pub 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");
Source

pub 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"]);
Source

pub 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"]);
Source

pub 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");
Source

pub 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"]);
Source

pub 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);
Source

pub 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");
Source

pub 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);
Source

pub 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");
Source

pub 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"]);
Source

pub 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"]);
Source

pub 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");
Source

pub 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);
Source

pub 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");
Source

pub 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);
Source

pub 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");
Source

pub 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);
Source

pub 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);
Source

pub 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);
Source

pub 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§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Decodable for Header

Source§

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

Deserialize a value using a Decoder.
Source§

impl Display for Header

Implement Display for Header

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Header

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Encodable for Header

Source§

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

Serialize a value using an Encoder.
Source§

impl ToJson for Header

Source§

fn to_json(&self) -> Json

Constructs the JSON reprezentation of Header.

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.