Repository: lettre/lettre (language: rust)

Issue:
lettre_email::EmailBuilder fails to build given an envelope with a valid from field.
**Describe the bug**
`lettre_email::EmailBuilder` fails to build the email and throws a MissingFrom error when building from an envelope, which provides the from field.

**To Reproduce**
```rust
fn main() {
    let e = Envelope::new(
        Some(EmailAddress::new("from@example.org".to_string()).unwrap()),
        vec![EmailAddress::new("to@example.org".to_string()).unwrap()],
    )
    .unwrap();

    let eb = EmailBuilder::new()
        .envelope(e)
        .subject("subject")
        .text("message")
        .build()
        .unwrap();
}
```

**Expected behavior**
 The email be built successfully

**Environment (please complete the following information):**
- 0.9
- Linux

**Additional context**
The example given in `lettre/examples/smtp.rs` does send an email given just the envelope, in comparison. The code below throws the error even if the envelope just above it contains the from field (since it isn't checked).
https://github.com/lettre/lettre/blob/c988b1760ad8179d9e7f3fb8594d2b86cf2a0a49/lettre_email/src/lib.rs#L430-L437

Thanks :)



Discussion / hints:

Fix patch:
diff --git a/lettre_email/src/lib.rs b/lettre_email/src/lib.rs
index 447587065..43211f8db 100644
--- a/lettre_email/src/lib.rs
+++ b/lettre_email/src/lib.rs
@@ -430,6 +430,10 @@ impl EmailBuilder {
         if !self.from.is_empty() {
             self.message = self.message
                 .header(Header::new_with_value("From".into(), self.from).unwrap());
+        } else if let Some(from) = envelope.from() {
+            let from = vec![Address::new_mailbox(from.to_string())];
+            self.message = self.message
+                .header(Header::new_with_value("From".into(), from).unwrap());
         } else {
             Err(EmailError::Envelope {
                 error: LettreError::MissingFrom,


Test patch:
diff --git a/lettre_email/tests/build_with_envelope.rs b/lettre_email/tests/build_with_envelope.rs
new file mode 100644
index 000000000..a2f157139
--- /dev/null
+++ b/lettre_email/tests/build_with_envelope.rs
@@ -0,0 +1,32 @@
+extern crate lettre_email;
+extern crate lettre;
+use lettre_email::EmailBuilder;
+use lettre::{EmailAddress, Envelope};
+
+#[test]
+fn build_with_envelope_test() {
+    let e = Envelope::new(
+        Some(EmailAddress::new("from@example.org".to_string()).unwrap()),
+        vec![EmailAddress::new("to@example.org".to_string()).unwrap()],
+    ).unwrap();
+    let _email = EmailBuilder::new()
+        .envelope(e)
+        .subject("subject")
+        .text("message")
+        .build()
+        .unwrap();
+}
+
+#[test]
+fn build_with_envelope_without_from_test() {
+    let e = Envelope::new(
+        None,
+        vec![EmailAddress::new("to@example.org".to_string()).unwrap()],
+    ).unwrap();
+    let _email = EmailBuilder::new()
+        .envelope(e)
+        .subject("subject")
+        .text("message")
+        .build()
+        .unwrap_err();
+}
\ No newline at end of file