feat(all): Merge Email and SendableEmail into lettre::Email

This commit is contained in:
Alexis Mousset
2019-12-18 16:51:04 +01:00
parent 5e521b0c82
commit ce37464050
22 changed files with 70 additions and 92 deletions

View File

@@ -23,10 +23,10 @@ fn build_with_envelope_without_from_test() {
vec![EmailAddress::new("to@example.org".to_string()).unwrap()],
)
.unwrap();
let _email = EmailBuilder::new()
assert!(EmailBuilder::new()
.envelope(e)
.subject("subject")
.text("message")
.build()
.unwrap_err();
.is_err());
}

View File

@@ -1,13 +1,13 @@
#[cfg(all(test, feature = "smtp-transport", feature = "connection-pool"))]
mod test {
use lettre::{ClientSecurity, EmailAddress, Envelope, SendableEmail, SmtpClient};
use lettre::{ClientSecurity, Email, EmailAddress, Envelope, SmtpClient};
use lettre::{SmtpConnectionManager, Transport};
use r2d2::Pool;
use std::sync::mpsc;
use std::thread;
fn email(message: &str) -> SendableEmail {
SendableEmail::new(
fn email(message: &str) -> Email {
Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],

View File

@@ -2,7 +2,7 @@
#[cfg(feature = "file-transport")]
mod test {
use lettre::file::FileTransport;
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
use lettre::{Email, EmailAddress, Envelope, Transport};
use std::env::temp_dir;
use std::fs::remove_file;
use std::fs::File;
@@ -11,7 +11,7 @@ mod test {
#[test]
fn file_transport() {
let mut sender = FileTransport::new(temp_dir());
let email = SendableEmail::new(
let email = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],

View File

@@ -2,12 +2,12 @@
#[cfg(feature = "sendmail-transport")]
mod test {
use lettre::sendmail::SendmailTransport;
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
use lettre::{Email, EmailAddress, Envelope, Transport};
#[test]
fn sendmail_transport_simple() {
let mut sender = SendmailTransport::new();
let email = SendableEmail::new(
let email = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],

View File

@@ -1,11 +1,11 @@
#[cfg(test)]
#[cfg(feature = "smtp-transport")]
mod test {
use lettre::{ClientSecurity, EmailAddress, Envelope, SendableEmail, SmtpClient, Transport};
use lettre::{ClientSecurity, Email, EmailAddress, Envelope, SmtpClient, Transport};
#[test]
fn smtp_transport_simple() {
let email = SendableEmail::new(
let email = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],

View File

@@ -1,11 +1,11 @@
use lettre::stub::StubTransport;
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
use lettre::{Email, EmailAddress, Envelope, Transport};
#[test]
fn stub_transport() {
let mut sender_ok = StubTransport::new_positive();
let mut sender_ko = StubTransport::new(Err(()));
let email_ok = SendableEmail::new(
let email_ok = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],
@@ -14,7 +14,7 @@ fn stub_transport() {
"id".to_string(),
"Hello ß☺ example".to_string().into_bytes(),
);
let email_ko = SendableEmail::new(
let email_ko = Email::new(
Envelope::new(
Some(EmailAddress::new("user@localhost".to_string()).unwrap()),
vec![EmailAddress::new("root@localhost".to_string()).unwrap()],