feat(transport-sendmail): Make the command parameter an OsStr
This commit is contained in:
@@ -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")]
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user