mail-core

Provides the core mail type Mail for the mail crate.


This crate provides the type called mail as well as ways to create it. It also provides the builder context interface and the Resource type, which is used to represent mail bodies. Especially such which are attachments or embedded images.

Example

``rust extern crate futures; // Note that themail` crate provides a facade re-exporting // all relevant parts. extern crate mailcore; extern crate mailinternals;

[macro_use]

extern crate mail_headers;

use std::str; use futures::Future;

use mail_internals::MailType;

// In the facade this is the headers module. use mailheaders::{ headers::*, headercomponents::Domain };

// In the facade this types (and the defaultimpl module) // are also exposed at top level use mailcore::{ Mail, defaultimpl::simplecontext, error::MailError };

fn printsomemail() -> Result<(), MailError> { // Domain will implement from_str in the future, // currently it doesn't have a validator/parser. // So this will become "example.com".parse() let domain = Domain::fromunchecked("example.com".toowned()); // Normally you create this once per application. let ctx = simple_context::new(domain, "xqi93".parse().expect("we know it's ascii")) .expect("this is basically: failed to get cwd from env");

let mut mail = Mail::plain_text("Hy there! 😁");
mail.insert_headers(headers! {
    _From: [("I'm Awesome 😁", "bla@examle.com")],
    _To: ["unknow@example.com"],
    Subject: "Hy there message 😁"
}?);

// We don't added any think which needs loading but we could have
// and all of it would have been loaded concurrent and async.
let encoded = mail.into_encodable_mail(ctx.clone())
    .wait()?
    .encode_into_bytes(MailType::Ascii)?;

let mail_str = str::from_utf8(&encoded).unwrap();
println!("{}", mail_str);
Ok(())

}

fn main() { printsomemail().unwrap() } ```

Documentation can be viewed on docs.rs (once it is published).

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.