Skip to content

Commit

Permalink
update dependencies (jonhoo#236)
Browse files Browse the repository at this point in the history
- updated lettre
  - required some changes to the imap_integration to support
- remove explicit hostname dep
  • Loading branch information
urkle committed Jul 30, 2022
1 parent 1ce4401 commit f616ea9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 55 deletions.
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ lazy_static = "1.4"
ouroboros = "0.15.0"

[dev-dependencies]
lettre = "0.9.2"
lettre_email = "0.9.2"
lettre = "0.10"
rustls-connector = "0.16.1"
structopt = "0.3"

# to make -Zminimal-versions work
encoding = "0.2.32"
hostname = "0.1.3"
failure = "0.1.8"
mime = "0.3.4"

Expand Down
104 changes: 52 additions & 52 deletions tests/imap_integration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern crate chrono;
extern crate imap;
extern crate lettre;
extern crate lettre_email;
extern crate native_tls;

use chrono::{FixedOffset, TimeZone};
Expand Down Expand Up @@ -87,17 +86,26 @@ fn session(user: &str) -> imap::Session<native_tls::TlsStream<TcpStream>> {
}

fn smtp(user: &str) -> lettre::SmtpTransport {
let creds = lettre::smtp::authentication::Credentials::new(user.to_string(), user.to_string());
lettre::SmtpClient::new(
&format!("{}:{}", test_smtp_host(), test_smtps_port()),
lettre::ClientSecurity::Wrapper(lettre::ClientTlsParameters {
connector: tls(),
domain: "smtp.example.com".to_string(),
}),
)
.unwrap()
.credentials(creds)
.transport()
use lettre::{
transport::smtp::{
authentication::Credentials,
client::{Tls, TlsParameters},
},
SmtpTransport,
};

let creds = Credentials::new(user.to_string(), user.to_string());
let hostname = test_smtp_host();
let tls = TlsParameters::builder(hostname.clone())
.dangerous_accept_invalid_certs(true)
.dangerous_accept_invalid_hostnames(true)
.build()
.unwrap();
SmtpTransport::builder_dangerous(hostname)
.port(test_smtps_port())
.tls(Tls::Wrapper(tls))
.credentials(creds)
.build()
}

#[test]
Expand Down Expand Up @@ -154,25 +162,23 @@ fn inbox() {
c.select("INBOX").unwrap();

// then send the e-mail
let mut s = smtp(to);
let e = lettre_email::Email::builder()
.from("sender@localhost")
.to(to)
let s = smtp(to);
let e = lettre::message::Message::builder()
.from("sender@localhost".parse().unwrap())
.to(to.parse().unwrap())
.subject("My first e-mail")
.text("Hello world from SMTP")
.build()
.body("Hello world from SMTP".to_string())
.unwrap();
s.send(e.into()).unwrap();
s.send(&e.into()).unwrap();

// send a second e-mail
let e = lettre_email::Email::builder()
.from("sender2@localhost")
.to(to)
let e = lettre::message::Message::builder()
.from("sender2@localhost".parse().unwrap())
.to(to.parse().unwrap())
.subject("My second e-mail")
.text("Hello world from SMTP")
.build()
.body("Hello world from SMTP".to_string())
.unwrap();
s.send(e.into()).unwrap();
s.send(&e.into()).unwrap();

wait_for_delivery();

Expand Down Expand Up @@ -281,15 +287,14 @@ fn inbox_uid() {
c.select("INBOX").unwrap();

// then send the e-mail
let mut s = smtp(to);
let e = lettre_email::Email::builder()
.from("sender@localhost")
.to(to)
let s = smtp(to);
let e = lettre::message::Message::builder()
.from("sender@localhost".parse().unwrap())
.to(to.parse().unwrap())
.subject("My first e-mail")
.text("Hello world from SMTP")
.build()
.body("Hello world from SMTP".to_string())
.unwrap();
s.send(e.into()).unwrap();
s.send(&e.into()).unwrap();

wait_for_delivery();

Expand Down Expand Up @@ -353,12 +358,11 @@ fn append() {
let to = "inbox-append1@localhost";

// make a message to append
let e: lettre::SendableEmail = lettre_email::Email::builder()
.from("sender@localhost")
.to(to)
let e: lettre::Message = lettre::message::Message::builder()
.from("sender@localhost".parse().unwrap())
.to(to.parse().unwrap())
.subject("My second e-mail")
.text("Hello world")
.build()
.body("Hello world".to_string())
.unwrap()
.into();

Expand All @@ -367,9 +371,7 @@ fn append() {
let mbox = "INBOX";
c.select(mbox).unwrap();
//append
c.append(mbox, e.message_to_string().unwrap().as_bytes())
.finish()
.unwrap();
c.append(mbox, &e.formatted()).finish().unwrap();

// now we should see the e-mail!
let inbox = c.uid_search("ALL").unwrap();
Expand Down Expand Up @@ -402,12 +404,11 @@ fn append_with_flags() {
let to = "inbox-append2@localhost";

// make a message to append
let e: lettre::SendableEmail = lettre_email::Email::builder()
.from("sender@localhost")
.to(to)
let e: lettre::Message = lettre::message::Message::builder()
.from("sender@localhost".parse().unwrap())
.to(to.parse().unwrap())
.subject("My third e-mail")
.text("Hello world")
.build()
.body("Hello world".to_string())
.unwrap()
.into();

Expand All @@ -417,7 +418,7 @@ fn append_with_flags() {
c.select(mbox).unwrap();
//append
let flags = vec![Flag::Seen, Flag::Flagged];
c.append(mbox, e.message_to_string().unwrap().as_bytes())
c.append(mbox, &e.formatted())
.flags(flags)
.finish()
.unwrap();
Expand Down Expand Up @@ -460,12 +461,11 @@ fn append_with_flags_and_date() {
let to = "inbox-append3@localhost";

// make a message to append
let e: lettre::SendableEmail = lettre_email::Email::builder()
.from("sender@localhost")
.to(to)
let e: lettre::Message = lettre::message::Message::builder()
.from("sender@localhost".parse().unwrap())
.to(to.parse().unwrap())
.subject("My third e-mail")
.text("Hello world")
.build()
.body("Hello world".to_string())
.unwrap()
.into();

Expand All @@ -477,7 +477,7 @@ fn append_with_flags_and_date() {
let date = FixedOffset::east(8 * 3600)
.ymd(2020, 12, 13)
.and_hms(13, 36, 36);
c.append(mbox, e.message_to_string().unwrap().as_bytes())
c.append(mbox, &e.formatted())
.flag(Flag::Seen)
.flag(Flag::Flagged)
.internal_date(date)
Expand Down

0 comments on commit f616ea9

Please sign in to comment.