Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ hyper-rustls = { version = "0.27.9", default-features = false, features = [
"logging",
"tls12",
] }
bytes = "1.12.1"

[dev-dependencies]
rstest = "0.26.1"
Expand Down
2 changes: 1 addition & 1 deletion src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<H: SmtpHandler + 'static> Service<Request<Incoming>> for MxDelivService<H>
}
};

transaction.envelope.data = body_bytes.to_vec();
transaction.envelope.data = body_bytes;

log::debug!("(HTTP) MAIL FROM:<{}>", transaction.envelope.mail_from);
for rcpt in &transaction.envelope.rcpt_to {
Expand Down
3 changes: 2 additions & 1 deletion src/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use bytes::Bytes;
use rstest::{fixture, rstest};
use testresult::TestResult;
use tokio::net::TcpStream;
Expand All @@ -212,7 +213,7 @@ mod tests {
let mut transaction = Transaction {
envelope: Envelope {
mail_from: address.to_string(),
data: eml.to_vec(),
data: Bytes::from_owner(eml.to_vec()),
rcpt_to: vec!["does.not.matter@example.org".to_string()],
},
..Default::default()
Expand Down
5 changes: 3 additions & 2 deletions src/smtp_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::smtp_responses::OK_250;
use crate::utils::{extract_address, log_eml};
use async_trait::async_trait;
use bytes::Bytes;
use memchr::{Memchr, memmem};
use std::fmt::Debug;
use std::sync::Arc;
Expand All @@ -22,7 +23,7 @@ pub struct Envelope {
/// It MUST end with `<CRLF>`, contain no bare `<CR>` or `<LF>`
/// and have all `<CRLF>.` sequences escaped with `.` according to
/// <https://www.rfc-editor.org/rfc/rfc5321.html#section-4.5.2>.
pub data: Vec<u8>,
pub data: Bytes,
}

/// Represent an ongoing SMTP transaction.
Expand Down Expand Up @@ -310,7 +311,7 @@ where
}
}

transaction.envelope.data = data;
transaction.envelope.data = Bytes::from_owner(data);

// Process the message
match handler.handle_data_dot(&mut transaction).await {
Expand Down
8 changes: 4 additions & 4 deletions src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ mod tests {
"b1@[127.0.0.1]".to_string(),
"b2@[127.0.0.1]".to_string(),
],
data: "message\r\n".as_bytes().to_vec(),
data: "message\r\n".into(),
};

let record = lmtp_send(&envelope).await?;
Expand Down Expand Up @@ -420,7 +420,7 @@ mod tests {
let mut envelope = Envelope {
mail_from: "sender@here".to_string(),
rcpt_to: vec!["a1@localhost".to_string(), "b1@[127.0.0.1]".to_string()],
data: "message\r\n".as_bytes().to_vec(),
data: "message\r\n".into(),
};

let (record_postfix_1, record_filtermail_1) = {
Expand Down Expand Up @@ -466,13 +466,13 @@ mod tests {
let envelope_1 = Envelope {
mail_from: "sender@here".to_string(),
rcpt_to: vec!["a1@localhost".to_string()],
data: "message\r\n".as_bytes().to_vec(),
data: "message\r\n".into(),
};

let envelope_2 = Envelope {
mail_from: "sender@here".to_string(),
rcpt_to: vec!["b1@[127.0.0.1]".to_string()],
data: "message\r\n".as_bytes().to_vec(),
data: "message\r\n".into(),
};

// 1
Expand Down
2 changes: 1 addition & 1 deletion src/transport/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ impl Worker {
builder = builder.header(HEADER_RCPT_TO, rcpt_to);
}

builder.body(http_body_util::Full::from(envelope.data.clone()))?
builder.body(http_body_util::Full::from(envelope.data.to_vec()))?
Comment thread
j-g00da marked this conversation as resolved.
};

let client = if allow_invalid_cert {
Expand Down