Merge pull request #407 from amousset/readme-0-9

fix(doc): README should be compatible with latest stabel release
This commit is contained in:
Alexis Mousset
2020-04-19 16:31:27 +02:00
committed by GitHub

View File

@@ -7,7 +7,7 @@
[![Crate](https://img.shields.io/crates/v/lettre.svg)](https://crates.io/crates/lettre)
[![Docs](https://docs.rs/lettre/badge.svg)](https://docs.rs/lettre/)
[![Required Rust version](https://img.shields.io/badge/rustc-1.40-green.svg)]()
[![Required Rust version](https://img.shields.io/badge/rustc-1.20-green.svg)]()
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
[![Gitter](https://badges.gitter.im/lettre/lettre.svg)](https://gitter.im/lettre/lettre?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
@@ -38,37 +38,36 @@ Lettre does not provide (for now):
## Example
This library requires Rust 1.40 or newer.
This library requires Rust 1.20 or newer.
To use this library, add the following to your `Cargo.toml`:
```toml
[dependencies]
lettre = "0.10"
lettre = "0.9"
lettre_email = "0.9"
```
```rust,no_run
extern crate lettre;
use lettre::{EmailTransport, SmtpTransport};
use lettre_email::EmailBuilder;
use std::path::Path;
use lettre::{SmtpClient, Transport, Message};
use std::convert::TryInto;
fn main() {
let email = Message::builder()
let email = EmailBuilder::new()
// Addresses can be specified by the tuple (email, alias)
.to(("user@example.org", "Firstname Lastname").try_into().unwrap())
.to(("user@example.org", "Firstname Lastname"))
// ... or by an address only
.from("user@example.com".parse().unwrap())
.from("user@example.com")
.subject("Hi, Hello world")
.body("Hello world.")
//.attachment_from_file(Path::new("Cargo.toml"), None, &TEXT_PLAIN)
// FIXME add back attachment example
.text("Hello world.")
.build()
.unwrap();
// Open a local connection on port 25
let mut mailer = SmtpClient::new_unencrypted_localhost().unwrap().transport();
let mut mailer = SmtpTransport::builder_unencrypted_localhost().unwrap()
.build();
// Send the email
let result = mailer.send(email);
let result = mailer.send(&email);
if result.is_ok() {
println!("Email sent");
@@ -77,7 +76,6 @@ fn main() {
}
assert!(result.is_ok());
}
```
## Testing