Replace email builder by a new implementation (#393)

* Update dependencies (#386)

* Update dependencies and set MSRV to 1.40

* update hyperx

* Use display instead of description for errors

* Make hostname an optional feature

* Envelope from headers

* Update hyperx to 1.0

* rename builder to message

* Cleanup and make Transport send Messages

* Update rustls from 0.16 to 0.17

* Move transports into a common folder

* Merge imports from same crate

* Add message creation example to the site

* Hide "extern crate" in doc examples

* Add References and In-Reply-To methods

* Add message-id header

* Add blog posts and improve doc examples
This commit is contained in:
Alexis Mousset
2020-04-18 23:10:03 +02:00
committed by GitHub
parent a440ae5c79
commit 53aa5b4df6
63 changed files with 3753 additions and 1513 deletions

View File

@@ -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) {
@@ -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());
})
@@ -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());
})