In the second case, you're parsing the string into email address, but in the first one you try to use the string directly and probably get a type mismatch. Message::builder().from(addr.parse().unwrap()) should work.
Side note - it'd be easier to help if you formatted your code and specified the exact error you've got from cargo check - for now, my answer is just a guess.
let e1 = "nomail@noserver.com";
let email = Message::builder()
.from(e1)
.to("nomail@noserver.com".parse().unwrap())
.subject("New IP found")
.body(body)
.unwrap();
.from(emailaddress)
| ---- ^^^^^^^^^^^^ expected struct `Mailbox`, found enum `Result`
| |
| arguments to this function are incorrect
Sorry, but the error refers to some other code (and this is only part of it) - there's no emailaddress here. Anyway, did you see the chapter on error handling in Rust book?
But it has already been explained to you that this is not the case. Please read the previous posts carefully. It doesn't matter whether a value comes from a literal or a variable, all that matters for the compiler is its type. If
.from("nomail@noserver.com")
works, then substituting it with the variable e1 will also work. Either both work or neither.