Improve doc
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
|
|
||||||
name = "lettre"
|
name = "lettre"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
description = "Email client"
|
description = "Email client"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
documentation = "http://lettre.github.io/lettre/"
|
documentation = "http://lettre.github.io/lettre/"
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ fn bench_simple_send(b: &mut test::Bencher) {
|
|||||||
#[bench]
|
#[bench]
|
||||||
fn bench_reuse_send(b: &mut test::Bencher) {
|
fn bench_reuse_send(b: &mut test::Bencher) {
|
||||||
let mut sender = SmtpTransportBuilder::new("127.0.0.1:2525")
|
let mut sender = SmtpTransportBuilder::new("127.0.0.1:2525")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.connection_reuse(true)
|
.connection_reuse(true)
|
||||||
.build();
|
.build();
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let email = EmailBuilder::new()
|
let email = EmailBuilder::new()
|
||||||
.to("root@localhost")
|
.to("root@localhost")
|
||||||
|
|||||||
135
src/lib.rs
135
src/lib.rs
@@ -5,72 +5,8 @@
|
|||||||
//! This mailer is divided into:
|
//! This mailer is divided into:
|
||||||
//!
|
//!
|
||||||
//! * An `email` part: builds the email message
|
//! * An `email` part: builds the email message
|
||||||
//! * A `transport` part: contains the available transports for your emails. To be sendable, the emails have to implement `SendableEmail`.
|
//! * A `transport` part: contains the available transports for your emails. To be sendable, the
|
||||||
//!
|
//! emails have to implement `SendableEmail`.
|
||||||
//! ## Stub transport
|
|
||||||
//!
|
|
||||||
//! The stub transport only logs message envelope and drops the content. It can be useful for testing purposes.
|
|
||||||
//!
|
|
||||||
//! ```rust
|
|
||||||
//! use lettre::transport::stub::StubEmailTransport;
|
|
||||||
//! use lettre::transport::EmailTransport;
|
|
||||||
//! use lettre::email::EmailBuilder;
|
|
||||||
//!
|
|
||||||
//! let mut sender = StubEmailTransport;
|
|
||||||
//! let email = EmailBuilder::new()
|
|
||||||
//! .to("root@localhost")
|
|
||||||
//! .from("user@localhost")
|
|
||||||
//! .body("Hello World!")
|
|
||||||
//! .subject("Hello")
|
|
||||||
//! .build()
|
|
||||||
//! .unwrap();
|
|
||||||
//! let result = sender.send(email);
|
|
||||||
//! assert!(result.is_ok());
|
|
||||||
//! ```
|
|
||||||
//!
|
|
||||||
//! Will log the line:
|
|
||||||
//!
|
|
||||||
//! ```text
|
|
||||||
//! b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
|
|
||||||
//! ```
|
|
||||||
//!
|
|
||||||
//! ## File transport
|
|
||||||
//!
|
|
||||||
//! The file transport writes the emails to the given directory. The name of the file will be `message_id.txt`.
|
|
||||||
//! It can be useful for testing purposes.
|
|
||||||
//!
|
|
||||||
//! ```rust
|
|
||||||
//! use std::env::temp_dir;
|
|
||||||
//!
|
|
||||||
//! use lettre::transport::file::FileEmailTransport;
|
|
||||||
//! use lettre::transport::EmailTransport;
|
|
||||||
//! use lettre::email::{EmailBuilder, SendableEmail};
|
|
||||||
//!
|
|
||||||
//! // Write to the local temp directory
|
|
||||||
//! let mut sender = FileEmailTransport::new(temp_dir());
|
|
||||||
//! let email = EmailBuilder::new()
|
|
||||||
//! .to("root@localhost")
|
|
||||||
//! .from("user@localhost")
|
|
||||||
//! .body("Hello World!")
|
|
||||||
//! .subject("Hello")
|
|
||||||
//! .build()
|
|
||||||
//! .unwrap();
|
|
||||||
//!
|
|
||||||
//! let result = sender.send(email);
|
|
||||||
//! assert!(result.is_ok());
|
|
||||||
//! ```
|
|
||||||
//! Example result in `/tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt`:
|
|
||||||
//!
|
|
||||||
//! ```text
|
|
||||||
//! b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
|
|
||||||
//! To: <root@localhost>
|
|
||||||
//! From: <user@localhost>
|
|
||||||
//! Subject: Hello
|
|
||||||
//! Date: Sat, 31 Oct 2015 13:42:19 +0100
|
|
||||||
//! Message-ID: <b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost>
|
|
||||||
//!
|
|
||||||
//! Hello World!
|
|
||||||
//! ```
|
|
||||||
//!
|
//!
|
||||||
//! ## SMTP transport
|
//! ## SMTP transport
|
||||||
//!
|
//!
|
||||||
@@ -188,6 +124,73 @@
|
|||||||
//! let _ = email_client.message("Test email");
|
//! let _ = email_client.message("Test email");
|
||||||
//! let _ = email_client.quit();
|
//! let _ = email_client.quit();
|
||||||
//! ```
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ## Stub transport
|
||||||
|
//!
|
||||||
|
//! The stub transport only logs message envelope and drops the content. It can be useful for
|
||||||
|
//! testing purposes.
|
||||||
|
//!
|
||||||
|
//! ```rust
|
||||||
|
//! use lettre::transport::stub::StubEmailTransport;
|
||||||
|
//! use lettre::transport::EmailTransport;
|
||||||
|
//! use lettre::email::EmailBuilder;
|
||||||
|
//!
|
||||||
|
//! let mut sender = StubEmailTransport;
|
||||||
|
//! let email = EmailBuilder::new()
|
||||||
|
//! .to("root@localhost")
|
||||||
|
//! .from("user@localhost")
|
||||||
|
//! .body("Hello World!")
|
||||||
|
//! .subject("Hello")
|
||||||
|
//! .build()
|
||||||
|
//! .unwrap();
|
||||||
|
//! let result = sender.send(email);
|
||||||
|
//! assert!(result.is_ok());
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! Will log the line:
|
||||||
|
//!
|
||||||
|
//! ```text
|
||||||
|
//! b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ## File transport
|
||||||
|
//!
|
||||||
|
//! The file transport writes the emails to the given directory. The name of the file will be
|
||||||
|
//! `message_id.txt`.
|
||||||
|
//! It can be useful for testing purposes.
|
||||||
|
//!
|
||||||
|
//! ```rust
|
||||||
|
//! use std::env::temp_dir;
|
||||||
|
//!
|
||||||
|
//! use lettre::transport::file::FileEmailTransport;
|
||||||
|
//! use lettre::transport::EmailTransport;
|
||||||
|
//! use lettre::email::{EmailBuilder, SendableEmail};
|
||||||
|
//!
|
||||||
|
//! // Write to the local temp directory
|
||||||
|
//! let mut sender = FileEmailTransport::new(temp_dir());
|
||||||
|
//! let email = EmailBuilder::new()
|
||||||
|
//! .to("root@localhost")
|
||||||
|
//! .from("user@localhost")
|
||||||
|
//! .body("Hello World!")
|
||||||
|
//! .subject("Hello")
|
||||||
|
//! .build()
|
||||||
|
//! .unwrap();
|
||||||
|
//!
|
||||||
|
//! let result = sender.send(email);
|
||||||
|
//! assert!(result.is_ok());
|
||||||
|
//! ```
|
||||||
|
//! Example result in `/tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt`:
|
||||||
|
//!
|
||||||
|
//! ```text
|
||||||
|
//! b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
|
||||||
|
//! To: <root@localhost>
|
||||||
|
//! From: <user@localhost>
|
||||||
|
//! Subject: Hello
|
||||||
|
//! Date: Sat, 31 Oct 2015 13:42:19 +0100
|
||||||
|
//! Message-ID: <b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost>
|
||||||
|
//!
|
||||||
|
//! Hello World!
|
||||||
|
//! ```
|
||||||
|
|
||||||
|
|
||||||
#![deny(missing_docs, unsafe_code, unstable_features)]
|
#![deny(missing_docs, unsafe_code, unstable_features)]
|
||||||
|
|||||||
Reference in New Issue
Block a user