[−][src]Module sparkpost::transmission
Module contains sprakpost email sending api
Example
extern crate sparkpost; use sparkpost::transmission::{Transmission, Message, EmailAddress, TransmissionResponse}; let tm = Transmission::new("api_key"); // to create for EU version use let tm = Transmission::new_eu("api_key"); let mut email: Message = Message::new( EmailAddress::new("marketing@company.com", "Example Company") ); email.add_recipient("name@domain.com") .subject("My Awesome email 😎") .html("<h1>html body of the email</h1>") .text("text body of the email"); let result = tm.send(&email); match result { Ok(res) => { println!("{:?}", &res); match res { TransmissionResponse::ApiResponse(api_res) => { // assert_eq!(1, api_res.total_accepted_recipients); // assert_eq!(0, api_res.total_rejected_recipients); } TransmissionResponse::ApiError(errors) => { println!("res: \n {:#?}", &errors); } } } Err(error) => { println!("error \n {:#?}", error); } }
Structs
ApiError | Transmission error returned by the API |
ApiResponse | Transmission result returned by the API |
Attachment | Attachment data |
EmailAddress | Email address with optional name |
Message | Represents email message including some mata-data |
Options | Message options for a particular Message |
Recipient | Email Recipient Example |
Transmission | Sparkpost Transmission currently only supports sending email message |
Enums
Recipients | |
TransmissionResponse | Wrapper Enum for ApiResponse and ApiError |
Type Definitions
ReqError | Reqwest Error |