From ca6399acbf8ec5447f874537f662abe5bcc66a0b Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Wed, 25 Nov 2020 20:35:25 +0100 Subject: [PATCH] add docs --- src/transport/file/mod.rs | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/transport/file/mod.rs b/src/transport/file/mod.rs index ac5287b..7b3bfca 100644 --- a/src/transport/file/mod.rs +++ b/src/transport/file/mod.rs @@ -30,6 +30,37 @@ //! # fn main() {} //! ``` //! +//! ## Sync example with envelope +//! +//! It is possible to also write the envelope content in a separate JSON file +//! by using the `with_envelope` builder. The JSON file will be written in the +//! target directory with same name and a `json` extension. +//! +//! ```rust +//! # use std::error::Error; +//! +//! # #[cfg(all(feature = "file-transport", feature = "builder"))] +//! # fn main() -> Result<(), Box> { +//! use std::env::temp_dir; +//! use lettre::{Transport, Message, FileTransport}; +//! +//! // Write to the local temp directory +//! let sender = FileTransport::with_envelope(temp_dir()); +//! let email = Message::builder() +//! .from("NoBody ".parse()?) +//! .reply_to("Yuin ".parse()?) +//! .to("Hei ".parse()?) +//! .subject("Happy new year") +//! .body("Be happy!")?; +//! +//! let result = sender.send(&email); +//! assert!(result.is_ok()); +//! # Ok(()) +//! # } +//! +//! # #[cfg(not(all(feature = "file-transport", feature = "builder")))] +//! # fn main() {} +//! ``` //! //! ## Async tokio 0.2 //! @@ -83,7 +114,7 @@ //! //! --- //! -//! Example result +//! Example email content result //! //! ```eml //! From: NoBody @@ -94,6 +125,12 @@ //! //! Be happy! //! ``` +//! +//! Example envelope result +//! +//! ```json +//! {"forward_path":["hei@domain.tld"],"reverse_path":"nobody@domain.tld"} +//! ``` pub use self::error::Error; use crate::address::Envelope;