Author: Kevin Schoon [me@kevinschoon.com]
Committer: Manos Pitsidianakis [manos@pitsidianak.is] Tue, 02 Jan 2024 14:12:46 +0000
Hash: a9a50f4659feab6c7d6e0f1d45cd7892687ccc68
Timestamp: Tue, 02 Jan 2024 14:12:46 +0000 (8 months ago)

+10 -0 +/-1 browse
add TO_ADDRESS as an environment variable for sendmail command
add TO_ADDRESS as an environment variable for sendmail command

This fixes a bug where when using the sendmail command the server sends mail
to the mailing list address rather than subscribers of the list. Additionally
if the sendmail command exits with a non-zero exit code mpot will now output
stderr for diagnostic purposes.
1diff --git a/cli/src/commands.rs b/cli/src/commands.rs
2index 8aebbf3..c4bbacb 100644
3--- a/cli/src/commands.rs
4+++ b/cli/src/commands.rs
5 @@ -637,6 +637,7 @@ pub fn flush_queue(db: &mut Connection, dry_run: bool, verbose: u8, debug: bool)
6 let mut child = std::process::Command::new("sh")
7 .arg("-c")
8 .arg(cmd)
9+ .env("TO_ADDRESS", msg.to_addresses.clone())
10 .stdout(Stdio::piped())
11 .stdin(Stdio::piped())
12 .stderr(Stdio::piped())
13 @@ -667,6 +668,15 @@ pub fn flush_queue(db: &mut Connection, dry_run: bool, verbose: u8, debug: bool)
14 process"
15 ))
16 })?;
17+ let result = child.wait_with_output()?;
18+ if !result.status.success() {
19+ return Err(Error::new_external(format!(
20+ "{} proccess failed with exit code: {:?}\n{}",
21+ cmd,
22+ result.status.code(),
23+ String::from_utf8(result.stderr).unwrap()
24+ )));
25+ }
26 Ok::<(), Error>(())
27 })?;
28 Ok(())