Repository: Wulf/create-rust-app (language: rust)

Issue:
Template mailer settings query
Great project, have enjoyed using it - thanks! 

I've got a query about some of the mailer settings that are used in the project:

It looks like there's an environment variable, `SEND_EMAIL` checked here:
https://github.com/Wulf/create-rust-app/blob/321b726359d679c64251504cb635ecc045e87ce3/template/backend/mail/mod.rs#L27

But further down there is some validation that looks for a different environment variable `SEND_MAIL`:
https://github.com/Wulf/create-rust-app/blob/321b726359d679c64251504cb635ecc045e87ce3/template/backend/mail/mod.rs#L65

Was it intended for there to be two different settings to control separate behaviours? The check also appears to print an error message (that at face value sounds contradictory) if `SEND_MAIL` is set to true.


Discussion / hints:
hey @katherine-sussol , thanks for reporting this!

That's a bug 😅. (It should be `"SEND_MAIL"`)

Also, there should be a `!` in front of `std::env::var("SEND_MAIL").unwrap().eq("true")`. It's on this line:
https://github.com/Wulf/create-rust-app/blob/main/template/backend/mail/mod.rs#L65

Feel free to create a PR, otherwise, I can do it as well :-)

We're going to make some changes which make it easier for these bug fixes to propagate to existing `create-rust-app` projects.

Fix patch:
diff --git a/template/backend/mail/mod.rs b/template/backend/mail/mod.rs
index 78072183..dba15811 100644
--- a/template/backend/mail/mod.rs
+++ b/template/backend/mail/mod.rs
@@ -24,7 +24,7 @@ impl Mailer {
         let smtp_server: String = env::var("SMTP_SERVER", "");
         let smtp_username: String = env::var("SMTP_USERNAME", "");
         let smtp_password: String = env::var("SMTP_PASSWORD", "");
-        let actually_send: bool = env::var("SEND_EMAIL", "false").eq("true");
+        let actually_send: bool = env::var("SEND_MAIL", "false").eq("true");
 
         return Mailer {
             from_address: from_address,
@@ -62,9 +62,9 @@ impl Mailer {
             println!("Note: SMTP_PASSWORD environment variable is not set, no mail will be sent!");
         }
 
-        if std::env::var("SEND_EMAIL").is_err() || std::env::var("SEND_MAIL").unwrap().eq("true") {
+        if std::env::var("SEND_MAIL").is_err() || !std::env::var("SEND_MAIL").unwrap().eq("true") {
             println!(
-                "Note: SEND_MAIL environment variale is not set to \"true\", no mail will be sent!"
+                "Note: SEND_MAIL environment variable is not set to \"true\", no mail will be sent!"
             );
         }
     }


Test patch: