Repository: lettre/lettre (language: rust)

Issue:
Sendmail should look in PATH by default.
**Describe the bug**

```
internal client error: No such file or directory (os error 2)
```

This happens when creating a transport like `lettre::AsyncSendmailTransport::new();`

This is surprising because sendmail is on my path.

This can be worked around by using `lettre::AsyncSendmailTransport::new_with_command("sendmail")`.

**To Reproduce**
```rust
let t = lettre::AsyncSendmailTransport::new();
lettre::AsyncTransport::send(&t, email).await?;
```

**Expected behavior**
It uses sendmail.

**Environment (please complete the following information):**
- Lettre version: 0.10.0-rc.3
- OS: Linux

**Additional context**
The problem is that `new()` uses the hardcoded absolute path `/usr/sbin/sendmail`.

https://github.com/lettre/lettre/blob/3e8988ae55650d03a352bf1dcbec5430e5c7ca3b/src/transport/sendmail/mod.rs#L95

This would technically be a breaking change, but since this is still rc.3 maybe we can sneak it in. Alternatively it can use the hardcoded path first (or as a fallback)? and search the path if not found.



Discussion / hints:
Hey, would my approach with https://github.com/de-sh/lettre/commit/fbd3300f46beacffe0c6a4d9c06d1783d95bdd6a be the right one?

I basically imported a new dependency, [`which`](https://crates.io/crates/which).
That would work. It might be easier to just pass "sendmail" to Command and it will look up the path itself. I guess this is probably slightly more efficient though because it caches the value 🤷
> It might be easier to just pass "sendmail" to Command and it will look up the path itself

What do you think @amousset? I'm not sure what the advantage is to the current implementation. Just having it be "sendmail" sounds to me like an acceptable fix to this issue, if there are no objections
Using `sendmail` by default but still allowing to specify the binary is probably the best option :+1: 
... and as it should have no actual impact on existing users I'm ok with making the change in 0.10.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4675ba72e..95c4ee717 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,7 +31,8 @@ Several breaking changes were made between 0.9 and 0.10, but changes should be s
 * When the hostname feature is disabled or hostname cannot be fetched, `127.0.0.1` is used instead of `localhost` as EHLO parameter (for better RFC compliance and mail server compatibility)
 * The `new` method of `ClientId` is deprecated
 * Rename `serde-impls` feature to `serde`
-
+* The `SendmailTransport` now uses the `sendmail` command in current `PATH` by default instead of
+  `/usr/bin/sendmail`.
 
 #### Bug Fixes
 
diff --git a/src/transport/sendmail/mod.rs b/src/transport/sendmail/mod.rs
index d2ce55922..1c35b353b 100644
--- a/src/transport/sendmail/mod.rs
+++ b/src/transport/sendmail/mod.rs
@@ -92,7 +92,7 @@ use std::{
 
 mod error;
 
-const DEFAULT_SENDMAIL: &str = "/usr/sbin/sendmail";
+const DEFAULT_SENDMAIL: &str = "sendmail";
 
 /// Sends emails using the `sendmail` command
 #[derive(Debug, Clone)]
@@ -113,7 +113,10 @@ pub struct AsyncSendmailTransport<E: Executor> {
 }
 
 impl SendmailTransport {
-    /// Creates a new transport with the default `/usr/sbin/sendmail` command
+    /// Creates a new transport with the `sendmail` command
+    ///
+    /// Note: This uses the `sendmail` command in the current `PATH`. To use another command,
+    /// use [SendmailTransport::new_with_command].
     pub fn new() -> SendmailTransport {
         SendmailTransport {
             command: DEFAULT_SENDMAIL.into(),
@@ -147,7 +150,10 @@ impl<E> AsyncSendmailTransport<E>
 where
     E: Executor,
 {
-    /// Creates a new transport with the default `/usr/sbin/sendmail` command
+    /// Creates a new transport with the `sendmail` command
+    ///
+    /// Note: This uses the `sendmail` command in the current `PATH`. To use another command,
+    /// use [AsyncSendmailTransport::new_with_command].
     pub fn new() -> Self {
         Self {
             inner: SendmailTransport::new(),


Test patch: