feat(transport-sendmail): Make the command parameter an OsStr

This commit is contained in:
Alexis Mousset
2020-05-08 11:46:25 +02:00
parent 4f0ea6366c
commit 33b0a9e27d
3 changed files with 11 additions and 5 deletions

View File

@@ -17,7 +17,7 @@
//! * **native-tls**: TLS support with the `native-tls` crate
//! * **r2d2**: Connection pool for SMTP transport
//! * **log**: Logging using the `log` crate
//! * **serde**: Serilization/Deserialization of entities
//! * **serde**: Serialization/Deserialization of entities
//! * **hostname**: Ability to try to use actual hostname in SMTP transaction
#![doc(html_root_url = "https://docs.rs/lettre/0.10.0")]

View File

@@ -26,29 +26,32 @@
use crate::{transport::sendmail::error::Error, Envelope, Transport};
use std::{
convert::AsRef,
ffi::OsString,
io::prelude::*,
process::{Command, Stdio},
};
pub mod error;
const DEFAUT_SENDMAIL: &str = "/usr/sbin/sendmail";
/// Sends an email using the `sendmail` command
#[derive(Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SendmailTransport {
command: String,
command: OsString,
}
impl SendmailTransport {
/// Creates a new transport with the default `/usr/sbin/sendmail` command
pub fn new() -> SendmailTransport {
SendmailTransport {
command: "/usr/sbin/sendmail".to_string(),
command: DEFAUT_SENDMAIL.into(),
}
}
/// Creates a new transport to the given sendmail command
pub fn new_with_command<S: Into<String>>(command: S) -> SendmailTransport {
pub fn new_with_command<S: Into<OsString>>(command: S) -> SendmailTransport {
SendmailTransport {
command: command.into(),
}

View File

@@ -221,6 +221,9 @@ pub const SUBMISSION_PORT: u16 = 587;
/// Default submission over TLS port
pub const SUBMISSIONS_PORT: u16 = 465;
/// Default timeout
pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(60);
/// Accepted protocols by default.
/// This removes TLS 1.0 and 1.1 compared to tls-native defaults.
// This is also rustls' default behavior
@@ -286,7 +289,7 @@ impl SmtpTransport {
hello_name: ClientId::hostname(),
credentials: None,
authentication: DEFAULT_MECHANISMS.into(),
timeout: Some(Duration::new(60, 0)),
timeout: Some(DEFAULT_TIMEOUT),
tls: Tls::None,
#[cfg(feature = "r2d2")]
pool: None,