Skip to content

Commit

Permalink
Merge 8f0bc1f into a440ae5
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Apr 18, 2020
2 parents a440ae5 + 8f0bc1f commit 6975f87
Show file tree
Hide file tree
Showing 62 changed files with 3,749 additions and 1,507 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- uses: actions/checkout@master
- run: cargo install mdbook --no-default-features --features output,search
- run: cd website && mdbook build
- run: echo "lettre.at" > website/_book/html/CNAME
- run: echo "lettre.at" > website/book/html/CNAME
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.5.1
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./website/_book/html
PUBLISH_DIR: ./website/book/html
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode/
.project/
.idea/
lettre.sublime-*
lettre.iml
target/
/Cargo.lock
61 changes: 31 additions & 30 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ readme = "README.md"
homepage = "https://lettre.at"
repository = "https://github.com/lettre/lettre"
license = "MIT"
authors = ["Alexis Mousset <contact@amousset.me>"]
categories = ["email"]
keywords = ["email", "smtp", "mailer"]
authors = ["Alexis Mousset <contact@amousset.me>", "Kayo <kayo@illumium.org>"]
categories = ["email", "network-programming"]
keywords = ["email", "smtp", "mailer", "message", "sendmail"]
edition = "2018"

[badges]
Expand All @@ -17,41 +17,46 @@ is-it-maintained-open-issues = { repository = "lettre/lettre" }
maintenance = { status = "actively-developed" }

[dependencies]
base64 = { version = "^0.11", optional = true }
bufstream = { version = "^0.1", optional = true }
email = { version = "^0.0.20", optional = true }
fast_chemail = "^0.9"
hostname = { version = "^0.3", optional = true }
log = "^0.4"
mime = { version = "^0.3", optional = true }
native-tls = { version = "^0.2", optional = true }
nom = { version = "^5.0", optional = true }
r2d2 = { version = "^0.8", optional = true }
rustls = { version = "^0.16", optional = true }
serde = { version = "^1.0", optional = true, features = ["derive"] }
serde_json = { version = "^1.0", optional = true }
time = { version = "^0.2", optional = true }
uuid = { version = "^0.8", features = ["v4"], optional = true }
webpki = { version = "^0.21", optional = true }
base64 = { version = "0.12", optional = true }
bufstream = { version = "0.1", optional = true }
# TODO to 0.5
bytes = { version = "0.4", optional = true }
hostname = { version = "0.3", optional = true }
hyperx = { version = "1", optional = true, features = ["headers"] }
idna = "0.2"
log = "0.4"
uuid = { version = "0.8", features = ["v4"] }
mime = { version = "0.3", optional = true }
native-tls = { version = "0.2", optional = true }
nom = { version = "5", optional = true }
once_cell = "1"
quoted_printable = { version = "0.4", optional = true }
r2d2 = { version = "0.8", optional = true }
regex = "1"
rustls = { version = "0.17", optional = true }
serde = { version = "1", optional = true, features = ["derive"] }
serde_json = { version = "1", optional = true }
textnonce = { version = "0.7", optional = true }
webpki = { version = "0.21", optional = true }

[dev-dependencies]
criterion = "^0.3"
env_logger = "^0.7"
glob = "^0.3"
walkdir = "^2"
criterion = "0.3"
env_logger = "0.7"
glob = "0.3"
walkdir = "2"

[[bench]]
harness = false
name = "transport_smtp"

[features]
builder = ["email", "mime", "time", "base64", "uuid"]
builder = ["mime", "base64", "hyperx", "textnonce", "quoted_printable", "bytes"]
connection-pool = ["r2d2"]
default = ["file-transport", "smtp-transport", "sendmail-transport", "native-tls", "builder"]
default = ["file-transport", "smtp-transport", "hostname", "sendmail-transport", "native-tls", "builder"]
file-transport = ["serde", "serde_json"]
rustls-tls = ["webpki", "rustls"]
sendmail-transport = []
smtp-transport = ["bufstream", "base64", "nom", "hostname"]
smtp-transport = ["bufstream", "base64", "nom"]
unstable = []

[[example]]
Expand All @@ -61,7 +66,3 @@ required-features = ["smtp-transport"]
[[example]]
name = "smtp_gmail"
required-features = ["smtp-transport", "native-tls"]

[[example]]
name = "builder"
required-features = ["builder"]
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2014-2020 Alexis Mousset
Copyright (c) 2014-2020 Alexis Mousset <contact@amousset.me>
Copyright (c) 2018 K. <kayo@illumium.org>

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,37 @@ Lettre provides the following features:
* Secure delivery with SMTP using encryption and authentication
* Easy email builders

Lettre does not provide (for now):

* Async support
* Email parsing

## Example

This library requires Rust 1.40 or newer.
To use this library, add the following to your `Cargo.toml`:

```toml
[dependencies]
lettre = "0.9"
lettre = "0.10"
```

```rust,no_run
extern crate lettre;
use lettre::{SmtpClient, Transport, Email, builder::mime::TEXT_PLAIN};
use std::path::Path;
use lettre::{SmtpClient, Transport, Message};
use std::convert::TryInto;
fn main() {
let email = Email::builder()
let email = Message::builder()
// Addresses can be specified by the tuple (email, alias)
.to(("user@example.org", "Firstname Lastname"))
.to(("user@example.org", "Firstname Lastname").try_into().unwrap())
// ... or by an address only
.from("user@example.com")
.from("user@example.com".parse().unwrap())
.subject("Hi, Hello world")
.text("Hello world.")
.attachment_from_file(Path::new("Cargo.toml"), None, &TEXT_PLAIN)
.unwrap()
.body("Hello world.")
//.attachment_from_file(Path::new("Cargo.toml"), None, &TEXT_PLAIN)
// FIXME add back attachment example
.build()
.unwrap();
Expand Down Expand Up @@ -88,4 +93,7 @@ this GitHub repository, must follow our [code of conduct](https://github.com/let

This program is distributed under the terms of the MIT license.

The builder comes from [emailmessage-rs](https://github.com/katyo/emailmessage-rs) by
Kayo, under MIT license.

See [LICENSE](./LICENSE) for details.
35 changes: 15 additions & 20 deletions benches/transport_smtp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use lettre::{
smtp::ConnectionReuseParameters, ClientSecurity, Email, EmailAddress, Envelope, SmtpClient,
Transport,
transport::smtp::ConnectionReuseParameters, ClientSecurity, Message, SmtpClient, Transport,
};

fn bench_simple_send(c: &mut Criterion) {
Expand All @@ -11,15 +10,13 @@ fn bench_simple_send(c: &mut Criterion) {

c.bench_function("send email", move |b| {
b.iter(|| {
let email = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],
)
.unwrap(),
"id".to_string(),
"Hello ß☺ example".to_string().into_bytes(),
);
let email = Message::builder()
.from("NoBody <nobody@domain.tld>".parse().unwrap())
.reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
.to("Hei <hei@domain.tld>".parse().unwrap())
.subject("Happy new year")
.body("Be happy!")
.unwrap();
let result = black_box(sender.send(email));
assert!(result.is_ok());
})
Expand All @@ -33,15 +30,13 @@ fn bench_reuse_send(c: &mut Criterion) {
.transport();
c.bench_function("send email with connection reuse", move |b| {
b.iter(|| {
let email = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],
)
.unwrap(),
"id".to_string(),
"Hello ß☺ example".to_string().into_bytes(),
);
let email = Message::builder()
.from("NoBody <nobody@domain.tld>".parse().unwrap())
.reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
.to("Hei <hei@domain.tld>".parse().unwrap())
.subject("Happy new year")
.body("Be happy!")
.unwrap();
let result = black_box(sender.send(email));
assert!(result.is_ok());
})
Expand Down
30 changes: 0 additions & 30 deletions examples/builder.rs

This file was deleted.

19 changes: 8 additions & 11 deletions examples/smtp.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
extern crate env_logger;
extern crate lettre;

use lettre::{Email, EmailAddress, Envelope, SmtpClient, Transport};
use lettre::{Message, SmtpClient, Transport};

fn main() {
env_logger::init();

let email = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],
)
.unwrap(),
"id".to_string(),
"Hello ß☺ example".to_string().into_bytes(),
);
let email = Message::builder()
.from("NoBody <nobody@domain.tld>".parse().unwrap())
.reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
.to("Hei <hei@domain.tld>".parse().unwrap())
.subject("Happy new year")
.body("Be happy!")
.unwrap();

// Open a local connection on port 25
let mut mailer = SmtpClient::new_unencrypted_localhost().unwrap().transport();
Expand Down
19 changes: 8 additions & 11 deletions examples/smtp_gmail.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
extern crate lettre;

use lettre::smtp::authentication::Credentials;
use lettre::{Email, EmailAddress, Envelope, SmtpClient, Transport};
use lettre::{transport::smtp::authentication::Credentials, Message, SmtpClient, Transport};

fn main() {
let email = Email::new(
Envelope::new(
Some(EmailAddress::new("from@gmail.com".to_string()).unwrap()),
vec![EmailAddress::new("to@example.com".to_string()).unwrap()],
)
.unwrap(),
"id".to_string(),
"Hello example".to_string().into_bytes(),
);
let email = Message::builder()
.from("NoBody <nobody@domain.tld>".parse().unwrap())
.reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
.to("Hei <hei@domain.tld>".parse().unwrap())
.subject("Happy new year")
.body("Be happy!")
.unwrap();

let creds = Credentials::new(
"example_username".to_string(),
Expand Down
Loading

0 comments on commit 6975f87

Please sign in to comment.