Compare commits

...

3 Commits

Author SHA1 Message Date
Alexis Mousset
a468cb3ab8 chore(all): 0.9.3 release 2020-04-19 10:56:46 +02:00
Alexis Mousset
9b591ff932 chore(all): Fix warnings 2020-04-19 10:24:23 +02:00
Alexis Mousset
eff4e1693f chore(builder): Update email to 0.0.21 2020-04-19 09:56:31 +02:00
12 changed files with 72 additions and 93 deletions

View File

@@ -1,3 +1,14 @@
<a name="v0.9.3"></a>
### v0.9.3 (2020-04-19)
#### Bug Fixes
* **all:**
* Fix compilation warnings ([9b591ff](https://github.com/lettre/lettre/commit/9b591ff932e35947f793aaaeec0e3f06e8818449))
* **email**
* Update `rust-email` to 0.0.21 ([eff4e169](https://github.com/lettre/lettre/commit/eff4e1693f5e65430b851707fdfd18046bc796e3))
<a name="v0.9.2"></a>
### v0.9.2 (2019-06-11)

View File

@@ -1,7 +1,7 @@
[package]
name = "lettre"
version = "0.9.2" # remember to update html_root_url
version = "0.9.3" # remember to update html_root_url
description = "Email client"
readme = "README.md"
homepage = "http://lettre.at"

View File

@@ -1,8 +1,8 @@
use self::Error::*;
use std::{
error::Error as StdError,
fmt::{self, Display, Formatter},
};
use self::Error::*;
/// Error type for email content
#[derive(Debug, Clone, Copy)]

View File

@@ -1,12 +1,12 @@
//! Error and result type for file transport
use self::Error::*;
use serde_json;
use std::io;
use std::{
error::Error as StdError,
fmt::{self, Display, Formatter},
};
use serde_json;
use std::io;
use self::Error::*;
/// An enum of all error kinds.
#[derive(Debug)]
@@ -21,20 +21,16 @@ pub enum Error {
impl Display for Error {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
fmt.write_str(self.description())
match *self {
Client(err) => fmt.write_str(err),
Io(ref err) => err.fmt(fmt),
JsonSerialization(ref err) => err.fmt(fmt),
}
}
}
impl StdError for Error {
fn description(&self) -> &str {
match *self {
Client(err) => err,
Io(ref err) => err.description(),
JsonSerialization(ref err) => err.description(),
}
}
fn cause(&self) -> Option<&StdError> {
fn cause(&self) -> Option<&dyn StdError> {
match *self {
Io(ref err) => Some(&*err),
JsonSerialization(ref err) => Some(&*err),

View File

@@ -3,7 +3,7 @@
//! This mailer contains the available transports for your emails.
//!
#![doc(html_root_url = "https://docs.rs/lettre/0.9.2")]
#![doc(html_root_url = "https://docs.rs/lettre/0.9.3")]
#![deny(
missing_copy_implementations,
trivial_casts,
@@ -30,11 +30,11 @@ extern crate serde;
#[cfg(feature = "serde-impls")]
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "file-transport")]
extern crate serde_json;
extern crate fast_chemail;
#[cfg(feature = "connection-pool")]
extern crate r2d2;
#[cfg(feature = "file-transport")]
extern crate serde_json;
pub mod error;
#[cfg(feature = "file-transport")]
@@ -73,7 +73,7 @@ pub struct EmailAddress(String);
impl EmailAddress {
pub fn new(address: String) -> EmailResult<EmailAddress> {
if !is_valid_email(&address) && !address.ends_with("localhost") {
Err(Error::InvalidEmailAddress)?;
return Err(Error::InvalidEmailAddress);
}
Ok(EmailAddress(address))
}
@@ -123,7 +123,7 @@ impl Envelope {
/// Creates a new envelope, which may fail if `to` is empty.
pub fn new(from: Option<EmailAddress>, to: Vec<EmailAddress>) -> EmailResult<Envelope> {
if to.is_empty() {
Err(Error::MissingTo)?;
return Err(Error::MissingTo);
}
Ok(Envelope {
forward_path: to,
@@ -143,7 +143,7 @@ impl Envelope {
}
pub enum Message {
Reader(Box<Read + Send>),
Reader(Box<dyn Read + Send>),
Bytes(Cursor<Vec<u8>>),
}
@@ -175,7 +175,7 @@ impl SendableEmail {
pub fn new_with_reader(
envelope: Envelope,
message_id: String,
message: Box<Read + Send>,
message: Box<dyn Read + Send>,
) -> SendableEmail {
SendableEmail {
envelope,

View File

@@ -1,11 +1,11 @@
//! Error and result type for sendmail transport
use self::Error::*;
use std::io;
use std::{
error::Error as StdError,
fmt::{self, Display, Formatter},
};
use self::Error::*;
use std::io;
/// An enum of all error kinds.
#[derive(Debug)]
@@ -18,19 +18,15 @@ pub enum Error {
impl Display for Error {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
fmt.write_str(self.description())
match *self {
Client(ref err) => err.fmt(fmt),
Io(ref err) => err.fmt(fmt),
}
}
}
impl StdError for Error {
fn description(&self) -> &str {
match *self {
Client(err) => err,
Io(ref err) => err.description(),
}
}
fn cause(&self) -> Option<&StdError> {
fn cause(&self) -> Option<&dyn StdError> {
match *self {
Io(ref err) => Some(&*err),
_ => None,

View File

@@ -72,7 +72,7 @@ impl<'a> Transport<'a> for SendmailTransport {
Ok(())
} else {
// TODO display stderr
Err(error::Error::Client("The message could not be sent"))?
Err(error::Error::Client("The message could not be sent"))
}
}
}

View File

@@ -193,7 +193,7 @@ impl<S: Connector + Write + Read + Timeout + Debug> InnerClient<S> {
}
/// Sends the message content
pub fn message(&mut self, message: Box<Read>) -> SmtpResult {
pub fn message(&mut self, message: Box<dyn Read>) -> SmtpResult {
let mut out_buf: Vec<u8> = vec![];
let mut codec = ClientCodec::new();

View File

@@ -245,7 +245,7 @@ impl AuthCommand {
challenge: Option<String>,
) -> Result<AuthCommand, Error> {
let response = if mechanism.supports_initial_response() || challenge.is_some() {
Some(mechanism.response(&credentials, challenge.as_ref().map(String::as_str))?)
Some(mechanism.response(&credentials, challenge.as_deref())?)
} else {
None
};

View File

@@ -42,36 +42,31 @@ pub enum Error {
impl Display for Error {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
fmt.write_str(self.description())
match *self {
// Try to display the first line of the server's response that usually
// contains a short humanly readable error message
Transient(ref err) => fmt.write_str(match err.first_line() {
Some(line) => line,
None => "transient error during SMTP transaction",
}),
Permanent(ref err) => fmt.write_str(match err.first_line() {
Some(line) => line,
None => "permanent error during SMTP transaction",
}),
ResponseParsing(err) => fmt.write_str(err),
ChallengeParsing(ref err) => err.fmt(fmt),
Utf8Parsing(ref err) => err.fmt(fmt),
Resolution => fmt.write_str("could not resolve hostname"),
Client(err) => fmt.write_str(err),
Io(ref err) => err.fmt(fmt),
Tls(ref err) => err.fmt(fmt),
Parsing(ref err) => fmt.write_str(err.description()),
}
}
}
impl StdError for Error {
#[cfg_attr(feature = "cargo-clippy", allow(clippy::match_same_arms))]
fn description(&self) -> &str {
match *self {
// Try to display the first line of the server's response that usually
// contains a short humanly readable error message
Transient(ref err) => match err.first_line() {
Some(line) => line,
None => "undetailed transient error during SMTP transaction",
},
Permanent(ref err) => match err.first_line() {
Some(line) => line,
None => "undetailed permanent error during SMTP transaction",
},
ResponseParsing(err) => err,
ChallengeParsing(ref err) => err.description(),
Utf8Parsing(ref err) => err.description(),
Resolution => "could not resolve hostname",
Client(err) => err,
Io(ref err) => err.description(),
Tls(ref err) => err.description(),
Parsing(ref err) => err.description(),
}
}
fn cause(&self) -> Option<&StdError> {
fn cause(&self) -> Option<&dyn StdError> {
match *self {
ChallengeParsing(ref err) => Some(&*err),
Utf8Parsing(ref err) => Some(&*err),

View File

@@ -1,7 +1,7 @@
[package]
name = "lettre_email"
version = "0.9.2" # remember to update html_root_url
version = "0.9.3" # remember to update html_root_url
description = "Email builder"
readme = "README.md"
homepage = "http://lettre.at"
@@ -23,7 +23,7 @@ lettre = { version = "^0.9", path = "../lettre", features = ["smtp-transport"] }
glob = "0.3"
[dependencies]
email = "^0.0.20"
email = "^0.0.21"
mime = "^0.3"
time = "^0.1"
uuid = { version = "^0.7", features = ["v4"] }

View File

@@ -1,7 +1,7 @@
//! Lettre is a mailer written in Rust. lettre_email provides a simple email builder.
//!
#![doc(html_root_url = "https://docs.rs/lettre_email/0.9.2")]
#![doc(html_root_url = "https://docs.rs/lettre_email/0.9.3")]
#![deny(
missing_docs,
missing_debug_implementations,
@@ -16,9 +16,9 @@
extern crate base64;
extern crate email as email_format;
extern crate lettre;
pub extern crate mime;
extern crate time;
extern crate uuid;
pub extern crate mime;
pub mod error;
@@ -301,10 +301,7 @@ impl EmailBuilder {
pub fn text<S: Into<String>>(self, body: S) -> EmailBuilder {
let text = PartBuilder::new()
.body(body)
.header((
"Content-Type",
mime::TEXT_PLAIN_UTF_8.to_string(),
))
.header(("Content-Type", mime::TEXT_PLAIN_UTF_8.to_string()))
.build();
self.child(text)
}
@@ -313,10 +310,7 @@ impl EmailBuilder {
pub fn html<S: Into<String>>(self, body: S) -> EmailBuilder {
let html = PartBuilder::new()
.body(body)
.header((
"Content-Type",
mime::TEXT_HTML_UTF_8.to_string(),
))
.header(("Content-Type", mime::TEXT_HTML_UTF_8.to_string()))
.build();
self.child(html)
}
@@ -329,18 +323,12 @@ impl EmailBuilder {
) -> EmailBuilder {
let text = PartBuilder::new()
.body(body_text)
.header((
"Content-Type",
mime::TEXT_PLAIN_UTF_8.to_string(),
))
.header(("Content-Type", mime::TEXT_PLAIN_UTF_8.to_string()))
.build();
let html = PartBuilder::new()
.body(body_html)
.header((
"Content-Type",
mime::TEXT_HTML_UTF_8.to_string(),
))
.header(("Content-Type", mime::TEXT_HTML_UTF_8.to_string()))
.build();
let alternate = PartBuilder::new()
@@ -399,7 +387,7 @@ impl EmailBuilder {
}
}
let from = Some(EmailAddress::from_str(&match self.sender {
Some(x) => Ok(x.address.clone()), // if we have a sender_header, use it
Some(x) => Ok(x.address), // if we have a sender_header, use it
None => {
// use a from header
debug_assert!(self.from.len() <= 1); // else we'd have sender_header
@@ -411,15 +399,11 @@ impl EmailBuilder {
// if it's an author group, use the first author
Some(mailbox) => Ok(mailbox.address.clone()),
// for an empty author group (the rarest of the rare cases)
None => Err(Error::Envelope(
LettreError::MissingFrom,
)), // empty envelope sender
None => Err(Error::Envelope(LettreError::MissingFrom)), // empty envelope sender
},
},
// if we don't have a from header
None => Err(Error::Envelope(
LettreError::MissingFrom,
)), // empty envelope sender
None => Err(Error::Envelope(LettreError::MissingFrom)), // empty envelope sender
}
}
}?)?);
@@ -443,9 +427,7 @@ impl EmailBuilder {
.message
.header(Header::new_with_value("From".into(), from).unwrap());
} else {
Err(Error::Envelope(
LettreError::MissingFrom,
))?;
return Err(Error::Envelope(LettreError::MissingFrom));
}
if !self.cc.is_empty() {
self.message = self
@@ -597,5 +579,4 @@ mod test {
.as_slice()
);
}
}