Compare commits
10 Commits
better-tls
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12dccd2bbe | ||
|
|
7899da9672 | ||
|
|
a85fdefe6f | ||
|
|
b73611c67f | ||
|
|
55cea7dbe6 | ||
|
|
d2b9d50000 | ||
|
|
3d16344d53 | ||
|
|
8873153178 | ||
|
|
b073df7666 | ||
|
|
cf6b767a9c |
48
CHANGELOG.md
48
CHANGELOG.md
@@ -1,3 +1,51 @@
|
||||
<a name="v0.11.19"></a>
|
||||
### v0.11.19 (2025-10-08)
|
||||
|
||||
#### Features
|
||||
|
||||
* Add raw header setter to `MessageBuilder` ([#1108])
|
||||
|
||||
#### Misc
|
||||
|
||||
* Fix README example ([#1114])
|
||||
* Replace custom `static_assert!` macro with `std::assert!` ([#1112])
|
||||
|
||||
[#1108]: https://github.com/lettre/lettre/pull/1108
|
||||
[#1112]: https://github.com/lettre/lettre/pull/1112
|
||||
[#1114]: https://github.com/lettre/lettre/pull/1114
|
||||
|
||||
<a name="v0.11.18"></a>
|
||||
### v0.11.18 (2025-07-28)
|
||||
|
||||
#### Features
|
||||
|
||||
* Allow inline attachments to be named ([#1101])
|
||||
|
||||
#### Misc
|
||||
|
||||
* Upgrade `socket2` to v0.6 ([#1098])
|
||||
|
||||
[#1098]: https://github.com/lettre/lettre/pull/1098
|
||||
[#1101]: https://github.com/lettre/lettre/pull/1101
|
||||
|
||||
<a name="v0.11.17"></a>
|
||||
### v0.11.17 (2025-06-06)
|
||||
|
||||
#### Features
|
||||
|
||||
* Add support for `rustls-platform-verifier` ([#1081])
|
||||
|
||||
#### Misc
|
||||
|
||||
* Change readme example to use `Mailbox::new` instead of string parsing ([#1090])
|
||||
* Replace futures-util `Mutex` with std `Mutex` in `AsyncStubTransport` ([#1091])
|
||||
* Avoid duplicate `abort_concurrent` implementation ([#1092])
|
||||
|
||||
[#1081]: https://github.com/lettre/lettre/pull/1081
|
||||
[#1090]: https://github.com/lettre/lettre/pull/1090
|
||||
[#1091]: https://github.com/lettre/lettre/pull/1091
|
||||
[#1092]: https://github.com/lettre/lettre/pull/1092
|
||||
|
||||
<a name="v0.11.16"></a>
|
||||
### v0.11.16 (2025-05-12)
|
||||
|
||||
|
||||
777
Cargo.lock
generated
777
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "lettre"
|
||||
# remember to update html_root_url and README.md (Cargo.toml example and deps.rs badge)
|
||||
version = "0.11.16"
|
||||
version = "0.11.19"
|
||||
description = "Email client"
|
||||
readme = "README.md"
|
||||
homepage = "https://lettre.rs"
|
||||
@@ -42,7 +42,7 @@ serde_json = { version = "1", optional = true }
|
||||
# smtp-transport
|
||||
nom = { version = "8", optional = true }
|
||||
hostname = { version = "0.4", optional = true } # feature
|
||||
socket2 = { version = "0.5.1", optional = true }
|
||||
socket2 = { version = "0.6", optional = true }
|
||||
url = { version = "2.4", optional = true }
|
||||
percent-encoding = { version = "2.3", optional = true }
|
||||
|
||||
|
||||
12
README.md
12
README.md
@@ -28,8 +28,8 @@
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
<a href="https://deps.rs/crate/lettre/0.11.16">
|
||||
<img src="https://deps.rs/crate/lettre/0.11.16/status.svg"
|
||||
<a href="https://deps.rs/crate/lettre/0.11.19">
|
||||
<img src="https://deps.rs/crate/lettre/0.11.19/status.svg"
|
||||
alt="dependency status" />
|
||||
</a>
|
||||
</div>
|
||||
@@ -67,15 +67,15 @@ lettre = "0.11"
|
||||
```
|
||||
|
||||
```rust,no_run
|
||||
use lettre::message::header::ContentType;
|
||||
use lettre::message::{Mailbox, header::ContentType};
|
||||
use lettre::transport::smtp::authentication::Credentials;
|
||||
use lettre::{Message, SmtpTransport, Transport};
|
||||
|
||||
fn main() {
|
||||
let email = Message::builder()
|
||||
.from(Mailbox::new("NoBody".to_owned(), "nobody@domain.tld".parse().unwrap()))
|
||||
.reply_to(Mailbox::new("Yuin".to_owned(), "yuin@domain.tld".parse().unwrap()))
|
||||
.to(Mailbox::new("Hei".to_owned(), "hei@domain.tld".parse().unwrap()))
|
||||
.from(Mailbox::new(Some("NoBody".to_owned()), "nobody@domain.tld".parse().unwrap()))
|
||||
.reply_to(Mailbox::new(Some("Yuin".to_owned()), "yuin@domain.tld".parse().unwrap()))
|
||||
.to(Mailbox::new(Some("Hei".to_owned()), "hei@domain.tld".parse().unwrap()))
|
||||
.subject("Happy new year")
|
||||
.header(ContentType::TEXT_PLAIN)
|
||||
.body(String::from("Be happy!"))
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
//! [mime 0.3]: https://docs.rs/mime/0.3
|
||||
//! [DKIM]: https://datatracker.ietf.org/doc/html/rfc6376
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/crate/lettre/0.11.16")]
|
||||
#![doc(html_root_url = "https://docs.rs/crate/lettre/0.11.19")]
|
||||
#![doc(html_favicon_url = "https://lettre.rs/favicon.ico")]
|
||||
#![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/15113230?v=4")]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
@@ -16,7 +16,10 @@ enum Disposition {
|
||||
/// File name
|
||||
Attached(String),
|
||||
/// Content id
|
||||
Inline(String),
|
||||
Inline {
|
||||
content_id: String,
|
||||
name: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Attachment {
|
||||
@@ -81,7 +84,50 @@ impl Attachment {
|
||||
/// ```
|
||||
pub fn new_inline(content_id: String) -> Self {
|
||||
Attachment {
|
||||
disposition: Disposition::Inline(content_id),
|
||||
disposition: Disposition::Inline {
|
||||
content_id,
|
||||
name: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new inline attachment giving it a name
|
||||
///
|
||||
/// This attachment should be displayed inline into the message
|
||||
/// body:
|
||||
///
|
||||
/// ```html
|
||||
/// <img src="cid:123">
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// ```rust
|
||||
/// # use std::error::Error;
|
||||
/// use std::fs;
|
||||
///
|
||||
/// use lettre::message::{header::ContentType, Attachment};
|
||||
///
|
||||
/// # fn main() -> Result<(), Box<dyn Error>> {
|
||||
/// let content_id = String::from("123");
|
||||
/// let file_name = String::from("image.jpg");
|
||||
/// # if false {
|
||||
/// let filebody = fs::read(&file_name)?;
|
||||
/// # }
|
||||
/// # let filebody = fs::read("docs/lettre.png")?;
|
||||
/// let content_type = ContentType::parse("image/jpeg").unwrap();
|
||||
/// let attachment =
|
||||
/// Attachment::new_inline_with_name(content_id, file_name).body(filebody, content_type);
|
||||
///
|
||||
/// // The image `attachment` will display inline into the email.
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn new_inline_with_name(content_id: String, name: String) -> Self {
|
||||
Attachment {
|
||||
disposition: Disposition::Inline {
|
||||
content_id,
|
||||
name: Some(name),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +141,18 @@ impl Attachment {
|
||||
Disposition::Attached(filename) => {
|
||||
builder.header(header::ContentDisposition::attachment(&filename))
|
||||
}
|
||||
Disposition::Inline(content_id) => builder
|
||||
Disposition::Inline {
|
||||
content_id,
|
||||
name: None,
|
||||
} => builder
|
||||
.header(header::ContentId::from(format!("<{content_id}>")))
|
||||
.header(header::ContentDisposition::inline()),
|
||||
Disposition::Inline {
|
||||
content_id,
|
||||
name: Some(name),
|
||||
} => builder
|
||||
.header(header::ContentId::from(format!("<{content_id}>")))
|
||||
.header(header::ContentDisposition::inline_with_name(&name)),
|
||||
};
|
||||
builder = builder.header(content_type);
|
||||
builder.body(content)
|
||||
@@ -142,4 +197,24 @@ mod tests {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn attachment_inline_with_name() {
|
||||
let id = String::from("id");
|
||||
let name = String::from("test");
|
||||
let part = super::Attachment::new_inline_with_name(id, name).body(
|
||||
String::from("Hello world!"),
|
||||
ContentType::parse("text/plain").unwrap(),
|
||||
);
|
||||
assert_eq!(
|
||||
&String::from_utf8_lossy(&part.formatted()),
|
||||
concat!(
|
||||
"Content-ID: <id>\r\n",
|
||||
"Content-Disposition: inline; filename=\"test\"\r\n",
|
||||
"Content-Type: text/plain\r\n",
|
||||
"Content-Transfer-Encoding: 7bit\r\n\r\n",
|
||||
"Hello world!\r\n"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,21 +186,15 @@ impl HeaderName {
|
||||
|
||||
/// Creates a new header name, panics on invalid name
|
||||
pub const fn new_from_ascii_str(ascii: &'static str) -> Self {
|
||||
macro_rules! static_assert {
|
||||
($condition:expr) => {
|
||||
let _ = [()][(!($condition)) as usize];
|
||||
};
|
||||
}
|
||||
|
||||
static_assert!(!ascii.is_empty());
|
||||
static_assert!(ascii.len() <= 76);
|
||||
assert!(!ascii.is_empty());
|
||||
assert!(ascii.len() <= 76);
|
||||
assert!(ascii.is_ascii());
|
||||
|
||||
let bytes = ascii.as_bytes();
|
||||
let mut i = 0;
|
||||
while i < bytes.len() {
|
||||
static_assert!(bytes[i].is_ascii());
|
||||
static_assert!(bytes[i] != b' ');
|
||||
static_assert!(bytes[i] != b':');
|
||||
assert!(bytes[i] != b' ');
|
||||
assert!(bytes[i] != b':');
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ mod mimebody;
|
||||
|
||||
use crate::{
|
||||
address::Envelope,
|
||||
message::header::{ContentTransferEncoding, Header, Headers, MailboxesHeader},
|
||||
message::header::{ContentTransferEncoding, Header, HeaderValue, Headers, MailboxesHeader},
|
||||
Error as EmailError,
|
||||
};
|
||||
|
||||
@@ -369,6 +369,12 @@ impl MessageBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Set raw custom header to message
|
||||
pub fn raw_header(mut self, raw_header: HeaderValue) -> Self {
|
||||
self.headers.insert_raw(raw_header);
|
||||
self
|
||||
}
|
||||
|
||||
/// Add mailbox to header
|
||||
pub fn mailbox<H: Header + MailboxesHeader>(self, header: H) -> Self {
|
||||
match self.headers.get::<H>() {
|
||||
@@ -711,7 +717,10 @@ mod test {
|
||||
.header(header::To(
|
||||
vec!["Pony O.P. <pony@domain.tld>".parse().unwrap()].into(),
|
||||
))
|
||||
.header(header::Subject::from(String::from("яңа ел белән!")))
|
||||
.raw_header(header::HeaderValue::new(
|
||||
header::HeaderName::new_from_ascii_str("Subject"),
|
||||
"яңа ел белән!".to_owned(),
|
||||
))
|
||||
.body(String::from("Happy new year!"))
|
||||
.unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user