pub struct Header { /* private fields */ }
Implementations§
Source§impl Header
impl Header
Sourcepub fn new() -> Header
pub fn new() -> Header
Constructs a new Header
.
§Examples
use smtpapi::{Header};
let header = Header::new();
println!("{}", header.to_json_string());
Sourcepub fn to_json_string(&self) -> String
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());
Sourcepub fn add_to<S>(&mut self, email: S) -> &mut Header
pub fn add_to<S>(&mut self, email: S) -> &mut Header
It appends a single email to the To header
§Examples
use smtpapi::{Header};
let mut header = Header::new();
header.add_to("email@domain.com");
Sourcepub fn add_tos<S>(&mut self, emails: Vec<S>) -> &mut Header
pub fn add_tos<S>(&mut self, emails: Vec<S>) -> &mut Header
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"]);
Sourcepub fn set_tos<S>(&mut self, emails: Vec<S>) -> &mut Header
pub fn set_tos<S>(&mut self, emails: Vec<S>) -> &mut Header
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"]);
Sourcepub fn add_substitution<S>(&mut self, key: S, sub: S) -> &mut Header
pub fn add_substitution<S>(&mut self, key: S, sub: S) -> &mut Header
It adds a new substitution to a specific key
§Examples
use smtpapi::{Header};
let mut header = Header::new();
header.add_substitution("[name]", "my_name");
Sourcepub fn add_substitutions<S>(&mut self, key: S, subs: Vec<&str>) -> &mut Header
pub fn add_substitutions<S>(&mut self, key: S, subs: Vec<&str>) -> &mut Header
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"]);
Sourcepub fn set_substitutions(
&mut self,
subs: HashMap<String, Vec<String>>,
) -> &mut Header
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);
Sourcepub fn add_section<S>(&mut self, section: S, value: S) -> &mut Header
pub fn add_section<S>(&mut self, section: S, value: S) -> &mut Header
It sets the value for a specific section
§Examples
use smtpapi::{Header};
let mut header = Header::new();
header.add_section("-top-", "sample");
Sourcepub fn set_sections(&mut self, sections: HashMap<String, String>) -> &mut Header
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);
Sourcepub fn add_category<S>(&mut self, category: S) -> &mut Header
pub fn add_category<S>(&mut self, category: S) -> &mut Header
It adds a new category to the Category header
§Examples
use smtpapi::{Header};
let mut header = Header::new();
header.add_category("welcome");
Sourcepub fn add_categories<S>(&mut self, categories: Vec<S>) -> &mut Header
pub fn add_categories<S>(&mut self, categories: Vec<S>) -> &mut Header
It adds multiple categories to the Category header
§Examples
use smtpapi::{Header};
let mut header = Header::new();
header.add_categories(vec!["welcome", "new_accounts"]);
Sourcepub fn set_categories<S>(&mut self, categories: Vec<S>) -> &mut Header
pub fn set_categories<S>(&mut self, categories: Vec<S>) -> &mut Header
It sets the value of the Categories field
§Examples
use smtpapi::{Header};
let mut header = Header::new();
header.set_categories(vec!["welcome", "new_accounts"]);
Sourcepub fn add_unique_arg<S>(&mut self, unique_arg: S, value: S) -> &mut Header
pub fn add_unique_arg<S>(&mut self, unique_arg: S, value: S) -> &mut Header
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");
Sourcepub fn set_unique_args(
&mut self,
unique_args: HashMap<String, String>,
) -> &mut Header
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);
Sourcepub fn add_filter<S>(
&mut self,
filter_name: S,
setting: S,
value: S,
) -> &mut Header
pub fn add_filter<S>( &mut self, filter_name: S, setting: S, value: S, ) -> &mut Header
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");
Sourcepub fn set_filter<S>(&mut self, filter: S, setting: Filter) -> &mut Header
pub fn set_filter<S>(&mut self, filter: S, setting: Filter) -> &mut Header
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);
Sourcepub fn set_ip_pool<S>(&mut self, name: S) -> &mut Header
pub fn set_ip_pool<S>(&mut self, name: S) -> &mut Header
It sets the value of the IpPool field
§Examples
use smtpapi::{Header};
let mut header = Header::new();
header.set_ip_pool("newsletter_pool");
Sourcepub fn set_asm_group_id(&mut self, asm_group_id: i32) -> &mut Header
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);
Sourcepub fn set_send_at(&mut self, send_at: i64) -> &mut Header
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);
Sourcepub fn add_send_each_at(&mut self, send_at: i64) -> &mut Header
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);
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)